-->
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.  [ 3 posts ] 
Author Message
 Post subject: Lazy Intialization of collections
PostPosted: Fri Jul 06, 2007 4:33 pm 
Newbie

Joined: Fri Jul 06, 2007 3:57 pm
Posts: 2
This must have been explained before. I have been looking at all the documentation to understand how lazy initialization works - but still have some questions.

For example, if
a cat has a list of kittens
and each kitten has a list of toys

Will calling Hibernate.initialize(cat)
Hibernate.initialize(cat.getKittens())

will it initialize list of toys for each kitten or
do I have to iterate through each kitten and initialize its collections.

Thanks so much. Any pointers or posts on this will help a lot.


Pramod


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jul 10, 2007 1:48 pm 
Expert
Expert

Joined: Sat Jan 17, 2004 2:57 pm
Posts: 329
Location: In the basement in my underwear
If the collections on the kittens are lazy then I believe it will NOT initialize them on its own. Just like initializing the cat didn't initialize the kittens.

In the end you can try it yourself, just code it up and then call isInitalized(whateverYouAreChecking).

_________________
Some people are like Slinkies - not really good for anything, but you still can't help but smile when you see one tumble down the stairs.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jul 10, 2007 4:22 pm 
Newbie

Joined: Mon Jul 02, 2007 2:12 pm
Posts: 18
jepp,

either iterate over kittens and initialize them or if you use criteria query then set FetchMode for them.

-Thomas


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 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.