-->
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 mapping entities and efficiency.
PostPosted: Fri Oct 26, 2007 12:19 pm 
Newbie

Joined: Fri Oct 26, 2007 12:13 pm
Posts: 1
Imagine that you have two objects, say Person and Event from the documentation. A person can have multiple event objects. Now imagine, that I have saved a person object which has twelve event objects associated with it.

If I make a change to the person object, but not to any of the events, and tell Hibernate to save the person object will it also make an update call for each of the twelve events?

If I make a change to the fourth event object in the person's list of twelve and then tell Hibernate to save the person will twelve update calls be made or just one?

If I retrieve the person object but never attempt to retrieve the person's events did any of the events get pulled from the database and placed into memory?

I'm curious how Hibernate deals with these sorts of optimization problems, any insight would be appreciated.

Thanks!


Top
 Profile  
 
 Post subject:
PostPosted: Sat Oct 27, 2007 8:14 am 
Beginner
Beginner

Joined: Mon Feb 19, 2007 4:22 am
Posts: 22
Location: Poland
Hi,

First question: only Person will be saved,

Second question: only one Event will be saved,

Third question: it depends, with default configuration events won't be loaded unless they are necessary. This behaviour is controlled by 'lazy' attribute on collection. Read about 'lazy' loading in manual.

I recommend studying logs from Hibernate. It may be confusing at the very beginning, but later on it gives lots of information about what Hibernate is exactly doing. Personally I have found them very useful in understanding Hibernate.


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.