-->
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: determining lazy loading at run time
PostPosted: Mon Mar 29, 2010 5:41 pm 
Newbie

Joined: Thu Mar 18, 2010 1:20 pm
Posts: 4
Hi All,

I was wondering if there is a way to dynamically determine if an object should be lazy loaded at run time? So basically I have an entity relation ship such as :

A Contains B

A Contains C

So depending on the business logic I am executing sometimes I want to eager load B and lazy load C and sometimes lazy load B and eager load C.

My apologies in advance if this has been addressed before , but I could not find anything that addresses this concern.

Cheers,
oodev


Top
 Profile  
 
 Post subject: Re: determining lazy loading at run time
PostPosted: Tue Mar 30, 2010 7:06 pm 
Newbie

Joined: Thu Mar 18, 2010 1:20 pm
Posts: 4
I really need an answer on this.

Can someone please point me to the right direction?

Cheers,
oodev


Top
 Profile  
 
 Post subject: Re: determining lazy loading at run time
PostPosted: Wed Mar 31, 2010 2:26 am 
Expert
Expert

Joined: Wed Mar 03, 2004 6:35 am
Posts: 1240
Location: Lund, Sweden
Define both associations as lazy. Then use HQL to load A and fetch join B or C when you want to load eagerly. For example:

Code:
select a from A a fetch join a.b where a......


More information is in the Hibernate documentation: http://docs.jboss.org/hibernate/stable/ ... yhql-joins


Top
 Profile  
 
 Post subject: Re: determining lazy loading at run time
PostPosted: Wed Mar 31, 2010 6:06 pm 
Newbie

Joined: Thu Mar 18, 2010 1:20 pm
Posts: 4
Thanks for the pointer, I will try to build that into my code.


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.