-->
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.  [ 5 posts ] 
Author Message
 Post subject: Lazy loading eager loading
PostPosted: Sat Dec 16, 2006 2:07 pm 
Beginner
Beginner

Joined: Sat Dec 16, 2006 1:52 pm
Posts: 40
I have an object that has children.

class Parent {
List children;
}

The children are lazy loaded. But I want them to be all loaded or none loaded. I do not want them loading one at a time. And I do not want them automatically loaded every time I load "Parent."

What is a good strategy to force all the children to be loaded at once when I am ready for them? Once this collection is loaded, it will change outside of a session. At some point I will want to have the changes saved. What is a good strategy for getting children updated to its new state?


I have been reading the documentation, but am quite new and recently from JDO which I know how to do this in. Wondering how I can do this with Hibernate.

Thanks!


Top
 Profile  
 
 Post subject: Re: Lazy loading eager loading
PostPosted: Sat Dec 16, 2006 3:27 pm 
Senior
Senior

Joined: Sun Jun 04, 2006 1:58 am
Posts: 136
dnoyeb wrote:
I have an object that has children.

class Parent {
List children;
}

The children are lazy loaded. But I want them to be all loaded or none loaded. I do not want them loading one at a time. And I do not want them automatically loaded every time I load "Parent."

What is a good strategy to force all the children to be loaded at once when I am ready for them? Once this collection is loaded, it will change outside of a session. At some point I will want to have the changes saved. What is a good strategy for getting children updated to its new state?


I have been reading the documentation, but am quite new and recently from JDO which I know how to do this in. Wondering how I can do this with Hibernate.

Thanks!


fetch = "subselect"

_________________
Don't forget to rate


Top
 Profile  
 
 Post subject:
PostPosted: Sat Dec 16, 2006 7:08 pm 
Beginner
Beginner

Joined: Sat Dec 16, 2006 1:52 pm
Posts: 40
I don't understand? Is this java code or metadata for the xml file?


Top
 Profile  
 
 Post subject:
PostPosted: Sun Dec 17, 2006 2:36 am 
Expert
Expert

Joined: Tue Dec 28, 2004 7:02 am
Posts: 573
Location: Toulouse, France
Anyway subselect is not yet supported in the code (by FetchMode for example).

So you just have to add the attribute fetch="subselect" in your <bag name="children" ...> (or <list>, anyway) line in your hbm.xml file.

_________________
Baptiste
PS : please don't forget to give credits below if you found this answer useful :)


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jan 22, 2007 3:06 pm 
Beginner
Beginner

Joined: Sat Dec 16, 2006 1:52 pm
Posts: 40
If I understand correctly, fetchmode does not have much to do with laziness directly. fetchmode just controls how much is fetched when something actually gets fetched. It does not control when something actually gets fetched.


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