-->
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: Setting the FetchMode at Runtime
PostPosted: Mon Oct 24, 2005 10:26 am 
Newbie

Joined: Mon Oct 24, 2005 10:13 am
Posts: 1
[b]Hibernate version: 2.1.7


I have defined a relationship between a "Batch" object and a collection of "Batch Records" with lazy loading turned off i.e. lazy="false". In most cases, when I retrieve a Batch, I want to retrieve all the Batch Records associated with that Batch so having turned off is working out good.

There is however one case where I want to tweak the performance and NOT retrieve all the Batch Records associated with a Batch. I tried to change the FetchMode at runtime using e.g. criteria.setFetchMode("batchRecords", FetchMode.LAZY). This still seems to retrieve all the Batch Records associated with a batch however. Am I missing something?

I see in Hibernate version 3 that FetchMode.LAZY and FetchMode.EAGER have been deprecated. Is this because you can't control 'what' is lazy loaded at runtime, but only 'how' it is retrieved i.e. by changing the status of the outer-join flag at runtime.

Finally, is the recommended approach to set lazy="true" if there is even just a single case where you dont want to load the associated collections of a Batch - and then change the fetch mode to EAGER or (JOIN) at run time?

Thanks


Top
 Profile  
 
 Post subject:
PostPosted: Mon Oct 24, 2005 10:35 am 
Expert
Expert

Joined: Fri Aug 19, 2005 2:11 pm
Posts: 628
Location: Cincinnati
I've found that setting lazy="true" on relationships is easier. It just seems that manually loading the collections in the code is easier than trying to override the lazy="false".

_________________
Chris

If you were at work doing this voluntarily, imagine what you'd want to see to answer a question.


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.