-->
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: Loading Objects in Hibernate
PostPosted: Wed Mar 28, 2012 3:03 am 
Newbie

Joined: Wed Jul 06, 2011 3:22 am
Posts: 5
Dear All,
I have one question i may call that as confusion which means that iam not clear on this concept.
I came across an article which was explaining Lazy Loading of Objects.
Here it is.
Consider below is the object graph

-A
|
*---B
| |
| *---C
| |
| *---D
| |
| *---E
| |
| *---F
| |
| *---G
*---H
It said if i want to load object 'C', all Parent and Child need to be loaded.
ie.,
Quote:
If you were to ask a naive O/R mapper to load C, it would have to load B (due to the parent reference). To load B, the O/R mapper then has to load D (due to the children reference). D then has to load E, F, and G. Then, to continue loading B, the O/R mapper has to load A, which then loads H.


For me it makes sense if it is enough just to load all the required Children as the associated(child) object should not be null.
Why the parent object need to be loaded?

Can any one explain me this?

Also please let me know if this concept is applicable in general or specific to HIBERNATE?

Thanks.

Regards
Senthil Kumar Sekar


Top
 Profile  
 
 Post subject: Re: Loading Objects in Hibernate
PostPosted: Wed Mar 28, 2012 3:52 am 
Newbie

Joined: Tue Nov 01, 2005 12:38 pm
Posts: 12
Hello Senthil,

B does not need to have a reference to its parent. If every object has an eager fetching reference to its parent and children, loading one object would cause everything to be loaded into memory.

So if B does not need to know its parent, don't reference it, then it wont be loaded. If it needs to know its parent you could make this reference lazy-loading, so it will only load A when you access the reference to A. But then you should also make the references from A to A's children lazy loading, so that loading A does not load everything into memory.

Regards,

Sven


Top
 Profile  
 
 Post subject: Re: Loading Objects in Hibernate
PostPosted: Wed Mar 28, 2012 4:02 am 
Newbie

Joined: Tue Nov 01, 2005 12:38 pm
Posts: 12
deleted


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.