-->
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: lazy loading
PostPosted: Fri May 16, 2008 6:24 am 
Newbie

Joined: Wed Jul 18, 2007 8:15 am
Posts: 9
Hi,
I have a problem in understanding this concept.Let assume the first request(http) fetched an object and that object has one to many association.So for hibernate to work lazily,i have to keep the session open if i want to fetch the collection in second request.But how to keep the session open and get that in the second request .Please if any one can explain in simple terms.

regards,
Ajse


Top
 Profile  
 
 Post subject:
PostPosted: Fri May 16, 2008 7:00 am 
Senior
Senior

Joined: Mon Feb 25, 2008 1:48 am
Posts: 191
Location: India
Hi Ajse,
Lazy initialization is mostly used within a request, not across multiple requests.

Lazy initialization is basically used to make sure you retreive only what you want in a particular point in time. So if you have a collection inside the object and you do not plan to use the collection during a request, lazy loading will save unwanted database hits and memory usage as well. In case you plan to use the collection in the request, you will initialize that collection inside the same session for that request.

PS: You can use the same session across multiple requests also but generally, its not considered to be good practise.

_________________
Sukirtha


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.