Bonjour,
Sur un projet EJB, j'utilise Spring pour initialiser et récupérer les instances de DAO.
Ces DAO héritent de org.springframework.orm.hibernate3.support.HibernateDaoSupport.
HibernateDaoSupport requière une sessionFactory.
Les entity utilisent les annotations JPA.
Dans le service-config.xml utilisé par Spring, j'indique qu'il faut fournir une AnnotationSessionFactoryBean dans la propriété sessionFactory de mon DAO (qui hérite de HibernateDaoSupport).
A l'appel de applicationContext.getBean("LeBeanDAO"), j'ai l'erreur :
Caused by: java.lang.IllegalArgumentException: Cannot convert value of type [org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean] to required type [org.hibernate.SessionFactory] for property 'sessionFactory': no matching editors or conversion strategy found
Service-config.xml
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33 <bean id="DAO" class="net.exemple.DAOimpl"> <property name="sessionFactory" ref="sessionFactoryBean"/> </bean> <bean id="dataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource"> <property name="driverClassName" value="com.mysql.jdbc.Driver"/> <property name="url" value="jdbc:mysql://"/> <property name="username" value=""/> <property name="password" value=""/> <property name="connectionProperties"> <props> <prop key="connection_type">mem:</prop> </props> </property> </bean> <bean id="sessionFactoryBean" class="org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean"> <property name="dataSource" ref="dataSource"/> <property name="annotatedPackages"> <list> <value>net.exemple</value> </list> </property> <property name="hibernateProperties"> <props> <prop key="hibernate.dialect">org.hibernate.dialect.MySQLDialect</prop> <prop key="hibernate.jdbc.batch_size">20</prop> <prop key="hibernate.hbm2ddl.auto">create-drop</prop> <prop key="hibernate.show_sql">true</prop> </props> </property> </bean>
Merci d'avance pour vos réponses.
Partager