No Hibernate Session bound to thread, and configuration does not allow creation of non-transactional one here?

I resolved this by adding Transactional to the base/generic bernate DAO implementation class (the parent class which implements the saveOrUpdate() method inherited by the DAO I use in the main program), i.e. The Transactional needs to be specified on the actual class which implements the method. My assumption was instead that if I declared Transactional on the child class then it included all of the methods that were inherited by the child class.

However it seems that the Transactional annotation only applies to methods implemented within a class and not to methods inherited by a class.

I resolved this by adding @Transactional to the base/generic bernate DAO implementation class (the parent class which implements the saveOrUpdate() method inherited by the DAO I use in the main program), i.e. The @Transactional needs to be specified on the actual class which implements the method. My assumption was instead that if I declared @Transactional on the child class then it included all of the methods that were inherited by the child class.

However it seems that the @Transactional annotation only applies to methods implemented within a class and not to methods inherited by a class.

I got the following error: org.hibernate. BernateException: No bernate Session bound to thread, and configuration does not allow creation of non-transactional one here at org.springframework.orm. SpringSessionContext.

CurrentSession(SpringSessionContext. Java:63) I fixed this by changing my hibernate properties file hibernate. Current_session_context_class=thread My code and configuration file as follows session = getgetSessionFactory().

GetCurrentSession(); session. BeginTransaction(); session. CreateQuery(Qry).executeUpdate(); session.getTransaction().commit(); on properties file hibernate.

Dialect=org.hibernate.dialect. MySQLDialect hibernate. Show_sql=true hibernate.

Query_factory_class=org.hibernate.hql.ast. ASTQueryTranslatorFactory hibernate. Current_session_context_class=thread on cofiguration file ${hibernate.

Dialect} ${hibernate. Show_sql} ${hibernate. Query_factory_class} true ${hibernate.

Current_session_context_class} Thanks, Ashok.

Have you got org.springframework.orm. Support. OpenSessionInViewFilter configured in webapp's web.

Xml (assuming your application is a webapp), or wrapping calls accordingly?

Thanks, but no, I'm not using this code within a web application. – James Adams Feb 14 at 14:20 Check this: forum.springsource. Org/archive/index.

Php/t-34856. Html – mindas Feb 14 at 14:31.

You are missing from your spring context so the annotations are not being scanned!

Thanks for the suggestion, unfortunately I tried adding this to my application context configuration and it brought no joy (and BTW I've never had to use that before to get the annotations to take effect). – James Adams Feb 15 at 15:25 Have you tried adding @Transactional to the method that calls the DAO method? It may seem a bit crazy, but it could be a result of the annotations being designed to work in a controller -> service -> DAO hierarchy and you seem to be skipping the service layer.

If your calling method is not within a spring bean you could either introduce a service layer or use declarative transaction management instead of annotations. – rjsang Feb 15 at 15:39 Thanks again, rjsang. It turns out that the solution does involve adding the @Transactional to other classes, but it was adding it to the base DAO class (where the saveOrUpdate() method is defined) that solved the problem.

I mistakenly assumed that you could add @Transactional to a class and have it take effect on all the methods inherited by that class, and apparently it doesn't work like that. So when I added @Transactional to my child DAO class that only affects the methods actually defined in that class and none of the methods inherited from the base/generic DAO class. – James Adams Feb 15 at 16:50.

I resolved this by adding Transactional to the base/generic Hibernate DAO implementation class (the parent class which implements the saveOrUpdate() method inherited by the DAO I use in the main program), i.e. The Transactional needs to be specified on the actual class which implements the method. My assumption was instead that if I declared Transactional on the child class then it included all of the methods that were inherited by the child class.

However it seems that the Transactional annotation only applies to methods implemented within a class and not to methods inherited by a class.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions