-->
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.  [ 4 posts ] 
Author Message
 Post subject: Saving resources! Not loading collections.
PostPosted: Tue Nov 04, 2003 4:59 pm 
Newbie

Joined: Thu Aug 28, 2003 3:58 pm
Posts: 19
Lets suppose I have a parent child relationship

1 Parent -> n Children

If I want to edit the Parent, I would not load all his children (I just want to set some fields).

Since Parent.getChildren() == null, does Hibernate kills all the relationship when I update the object?

Suppose also that 1 Parent has 1,000,000 children, and I want to add one clhid to that count. Do I have to load all the 1,000,000 children in teh collection, add 1, ad then update?

I mean, if u need to do this, it can become quite expensive dealing with collections.


Top
 Profile  
 
 Post subject: Mapping lazy
PostPosted: Tue Nov 04, 2003 5:20 pm 
Senior
Senior

Joined: Sun Aug 31, 2003 3:14 pm
Posts: 151
Location: Earth (at the moment)
Reread the documentation on lazy loading.

If you map the collection of children as lazy="true" then you can load the parent, change some properties and resave it without having to load the children (unless you reference the collection of children for some reason).

You can add a child to a bag without the bag being initialized, but I believe you can not add a child to a set without the set being initialized because it doesn't allow duplicates and the return result from Set.add() needs to be calculated.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Nov 04, 2003 6:00 pm 
Newbie

Joined: Thu Aug 28, 2003 3:58 pm
Posts: 19
Well, I could do the opposite also. Building an bidirectional association. So I persist the child passing the Parent as a parameter (with only the id set) instead of loading the parent, adding a child and persisting the parent.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Nov 05, 2003 12:13 pm 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
This is the purpose of inverse="true"
read http://www.hibernate.org/117.html#A8 and http://www.hibernate.org/155.html

_________________
Emmanuel


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