These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 
Author Message
 Post subject: Session Closing and Lazy Initializing
PostPosted: Mon Dec 06, 2004 6:08 pm 
Beginner
Beginner

Joined: Tue Oct 26, 2004 4:59 pm
Posts: 23
We are trying to give lazy initializing a try in an attempt to cut down on the number of selects hibernate does when loading an object.

We are using WebWork2. The problem I've run into is we close the session at the end of the action. When a JSP tries to access a collection we got lazy initialization errors that said the session was closed.

The real trick was that in this case I had two collections in this class. Whichever collection was mapped first in the hibernate map file would work but the second would not. Removing the session.close() from the action fixed the problem.

So my question is what is the ideal solution for closing hibernate sessions when the view (JSP in this case) needs access to it?

Thanks,
Karl


Top
 Profile  
 
 Post subject:
PostPosted: Mon Dec 06, 2004 6:23 pm 
Hibernate Team
Hibernate Team

Joined: Mon Aug 25, 2003 9:11 pm
Posts: 4592
Location: Switzerland
Close it after the view has been rendered completely, something that is known as "Open Session in View". Use that to search the Hibernate website. Look at the AdminApp demo application for Webwork interceptors.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.