This forum is now a read-only archive. All commenting, posting, registration services have been turned off. Those needing community support and/or wanting to ask questions should refer to the Tag/Forum map, and to http://spring.io/questions for a curated list of stackoverflow tags that Pivotal engineers, and the community, monitor.

No Hibernate Session bound to thread...

I have changed my web application to spring framework and have now following problem on connecting hibernate... Maybe you can look at my configurations and tell me what I am doing wrong...

Exception:

Code:

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.SpringSessionContext.currentSession(SpringSessionContext.java:63)
at org.hibernate.impl.SessionFactoryImpl.getCurrentSession(SessionFactoryImpl.java:574)
at de.myapp.persistenz.impl.BasicDAOImpl.getCurrentSession(BasicDAOImpl.java:35)
at de.myapp.persistenz.impl.BasicDAOImpl.findByCriteria(BasicDAOImpl.java:97)
at de.myapp.persistenz.impl.MailTriggerDAO.findByJobname(MailTriggerDAO.java:30)
...

Comment

Hey, I didn't find trasactions any where in your code. You can use either Programatic or Declarative trasctions.

getCurrentSession will get the session binded with the transaction. If you don't start the trasaction then there is no session available for you.

I am using annotation driven transaction-manager. I couldn't write any "@"-signs in my first post on this board, because it said to me, I may not enter URLs ... that's why I escaped the at-chars with an backslash.

I have now the following solution, I simply replaced the BasicDAOImpl by the following one, which uses HibernateTemplates...