Hi I am using hibernate JPA with spring and mongodb and i am running my application on Glassfish-4.0.
My service class is :
@Component
public class T
After integrating Spring 4 with Hibernate 5 in my project and experiencing this problem, I found that I could prevent the error from appearing by changing the way of getting the session from sessionFactory.openSession()
to sessionFactory.getCurrentSession()
.
the proper way to work out this bug may be keep using the same session for the binding transaction.opensession will always create a new session which doesnt like the former one holding a transaction configed.using getCurrentSession and adding additional property
works fine for me.