java - Executing query in afterTransactionBegin method of Hibernate interceptor -


i've added hibernate interceptor , overridden aftertransactionbegin method , i'm trying execute database query in method.

 public void aftertransactionbegin(transaction tx) {     log.info("transaction begin: {}", applicationcontext.getbean(itxndao.class).getcurrenttransactionid().tostring()); } 

but i'm getting

caused by: org.hibernate.hibernateexception: no session found current thread  @ org.springframework.orm.hibernate4.springsessioncontext.currentsession(springsessioncontext.java:106)  @ org.hibernate.internal.sessionfactoryimpl.getcurrentsession(sessionfactoryimpl.java:1039) 

which means transaction has not begun yet. there way can achieve this?

the transaction started when aftertransactionbegin interceptor method called. in case, have spring related issue.

make sure call dao logic service method that's annotated @transactional.


Comments

Popular posts from this blog

android - Pass an Serializable object in AIDL -

How to provide Authorization & Authentication using Asp.net, C#? -

How to use Authorization & Authentication in Asp.net, C#? -