-->
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: transitive persistence and lazy loading
PostPosted: Wed Sep 08, 2004 10:49 pm 
Regular
Regular

Joined: Tue Jul 13, 2004 2:27 am
Posts: 73
Location: Singapore
Hi,
A question on lazy loading. I have three class:

Class A has one-to-many association with Class B;
cascade="save-update" inverse="false" lazy="true"
Class B is defined as a List in Class A;
Class B has one-to-many association with Class C;
cascade="save-update" inverse="false" lazy="true"
Class C is defined as a List in Class B;


So when I retrieve Class A, Class B will be retrieve also;
But Class C is not;

1) Does it mean I have to manually retrieve C then ?
2) If the chain is longer (for example, Class C has one2many with Class D), does it mean that I should not use lazy loading ?

sorry too new to this.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Sep 09, 2004 12:22 am 
Regular
Regular

Joined: Thu Jul 01, 2004 12:13 am
Posts: 68
Location: San Diego, CA
If you're using lazy initialization like you show in the example, you can do a find() in either class A or B and the list will come back as uninitialized. You just need to do Hibernate.initialize() to inflate those Lists. I would always recommend using lazy initialization for the performance gain.

HTH,
Lou


Top
 Profile  
 
 Post subject:
PostPosted: Thu Sep 09, 2004 1:49 am 
Regular
Regular

Joined: Tue Jul 13, 2004 2:27 am
Posts: 73
Location: Singapore
If I use Spring framework, does it mean that I do not need to take care of this ?


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.