wood burning stoves 2.0*
The moose likes Object Relational Mapping and the fly likes avoiding initialization of hibernate objects Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Databases » Object Relational Mapping
Bookmark "avoiding initialization of hibernate objects" Watch "avoiding initialization of hibernate objects" New topic

avoiding initialization of hibernate objects

Joe May

Joined: Sep 28, 2009
Posts: 22

I have an application where we use hibernate and the transaction management is a lil messed up. We have a HibernateHelper class from which we open and close the hibernate session. We use Weblogic workshop 9.2 . Now we make calls from the controller to Hibernate Helper(which is of course in the dao layer) to get a session instance. Now this is the problem. Our helper class sets a session count variable everytime user tries to get a session object. If he tries to get a second session object within the same transaction, we just increment the variable and get the current open session and return it. We are also initializing the objects and directly using it in the jsp. And everytime he tries to close the session, the counter is decremented and when it becomes 0, only then we close the session. Now i checked up a few hibernate forums and they recommended opening the session thru a filter when an action starts and closing it thru another filter when the action completes. This way we can avoid the initialization. But the object is directly used in the jsp and hence if i remove the initialization , the jsp code will fail. Can anyone think of a work around? The problem with initialising is that it is common code used across multiple modules and hence objects that are actually unneccesary for a particular module also get initialized and this takes up time.

wood burning stoves
subject: avoiding initialization of hibernate objects
Similar Threads
[Hibernate] NoClassDefFoundError
Problem re-attaching transient objects
recovery from hibernate session closed
Jboss connection pooling timeout
i want to block a user after three successive wrong password entry