Je suis débutant avec Spring et tente d'utiliser ce dernier avec Hibernate3. (Je me base sur "12.2.5 Implementing DAO based on plain Hibernate 3 API" de la doc de spring)
Je suis bloqué à cette erreur:
org.hibernate.HibernateException: No Hibernate Session bound to thread, and configuration does not allow creation of non-transactional one here
Quelquechose m'aurait-il échappé ?
merci
dao:
context.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 public class DomaineDAOImpl implements DomaineDAO { private SessionFactory sessionFactory; public void setSessionFactory(SessionFactory sessionFactory) { this.sessionFactory = sessionFactory; } (...) public void saveDomaine(Domaine domaine) { this.sessionFactory.getCurrentSession().saveOrUpdate(domaine); } }
Trace:
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 <bean id="sessionFactory" class="org.springframework.orm.hibernate3.LocalSessionFactoryBean" name="sessionFactory"> <property name="dataSource"> <ref local="dataSource" /> </property> <property name="mappingDirectoryLocations"> <value>mappings</value> </property> <property name="hibernateProperties"> <props> <prop key="hibernate.dialect">${sessionFactory.hibernate.dialect}</prop> <prop key="hibernate.connection.pool_size">1</prop> <prop key="hibernate.hbm2ddl.auto">update</prop> <prop key="hibernate.show_sql">${sessionFactory.hibernate.show_sql}</prop> <prop key="hibernate.default_schema">${sessionFactory.hibernate.default_schema}</prop> </props> </property> </bean> <bean id="domaineDAO" class="dictionnaire.dao.hibernate.DomaineDAOImpl" name="domaineDAO"> <property name="sessionFactory" ref="sessionFactory"/> </bean>
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7 Exception in thread "main" org.hibernate.HibernateException: No Hibernate Session bound to thread, and configuration does not allow creation of non-transactional one here at org.springframework.orm.hibernate3.LocalSessionFactoryBean$TransactionAwareInvocationHandler.invoke(LocalSessionFactoryBean.java:1087) at $Proxy0.getCurrentSession(Unknown Source) at dictionnaire.dao.hibernate.DomaineDAOImpl.saveDomaine(DomaineDAOImpl.java:35) at dictionnaire.ProjetManager.createAndStoreProjetDomaine(ProjetManager.java:53) at dictionnaire.ProjetManager.main(ProjetManager.java:29)
Partager