-->
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: Question about lazy loading
PostPosted: Tue May 10, 2005 5:20 am 
Newbie

Joined: Wed Apr 13, 2005 8:10 am
Posts: 15
Hi,
Lets say I load an Object which is a root of a large relationships tree, some of it is retrieved in lazy mode.
Would the relationship expand also after I close the session?

I am asking this because I am working on a Web-App, in which there is a big amount data with complex relationships. This data does not change, and it would be better if I can retrieve it once, put it in the application context and use it from all servlet requests.

Cheers,
Ron


Top
 Profile  
 
 Post subject:
PostPosted: Tue May 10, 2005 10:27 am 
Regular
Regular

Joined: Mon Jul 26, 2004 2:28 pm
Posts: 86
Location: Pensacola, Florida
Once the session is closed you will receive an error to the effect of "LazyInitializationException: unable to lazily initialize a collection (no session or session closed)". The object is "detached" at that point and must be re-attached to become persistent.

You have to explicitly re-attach the object to a new session using session.lock( object, LockMode.NONE ) or session.update( object ) in order to continue using lazy initialization.

There are some strategies for handling this on the wiki:

http://hibernate.org/42.html
http://hibernate.org/168.html

I also highly recommend Hibernate in Action...I did not fully understand the implications of my design decisions until I read that book, and it covers long user transactions in greate detail.

- Jesse
[/url]


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.