Linoux wrote:
Hi !
I have exactly the same issue in my own project.
Did you find a way to resolve this ?
thanks
In this scenario, hibernate session is not a contextual session (
http://www.hibernate.org/hib_docs/v3/api/org/hibernate/context/CurrentSessionContext.html) in sense the session is not associated with the CMT.Both session and EJB's Transaction act independently each other.Here, Session serves as just a cache and JDBC connection, since from sessionfactory we are opening new connection everytime.So we have to explicitly flush the session using session.flush().It is inevitable with
sessionFactory.openSession().Because EJB won't flush the session, since it is not controling the session.So we have to flush(in simple terms, move the objects in cache to BD thru SQLs) explicitly.
To avoid explicit flushing of session, use
sessionFactory.getCurrentSession(), which will open a new session and bind for a JTA and give you same session within that transaction.plz refer
http://hibernate.org/42.html#A7.In this case when the system transaction commits (the EJB transaction completes), the Session is automatically flushed and closed.
Problem: sessionFactory.openSession()
Solution: sessionFactory.getCurrentSession()
Hope this would help you to fix the issue.else ping me at
athiganesh@gmail.com