I've run into a problem that so far I've been unable to find a work around for. In our web application we are using Hibernate 3.x (annotations) with the EntityManager to control our transactions and every time a call is made to the service layer from the client we have a servlet listener that intercepts and examines the request/session to make sure the user is already authenticated and if not authenticate them and add them to our DB. The problem is that when we try to persist the user to the data layer nothing happens since the hibernate session is closed.
I have tried multiple things to try and get the User object to persist including (but not limited to) trying to get/open a session by calling:
Code:
Session session = (Session) entityManger.getDelegate()
But no matter what I do the session is always closed and can’t be re-opened.
I was wondering if anyone else has encountered issues like this before and how they overcame them. We’re running our application in Tomcat 6x and are utilizing Spring MVC but are not using the MVC for the user authentication piece of the tool. Any help that can be given with this would be greatly appreciated.