-->
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: non-lazy fetching and caching
PostPosted: Mon Feb 20, 2006 9:32 am 
Newbie

Joined: Mon Feb 20, 2006 9:23 am
Posts: 9
I have a many-to-one relationship from class A to B; I've set lazy=false on that relationship in order to ensure that my loaded instances of A get 'real' (non-proxy) references to B.

I've also configured B so that it is cached (in the second level cache) and all of my queries for B are marked as cacheable the query cache.

From inspecting the Hibernate debug, it would appear that Hibernate only uses the session cache to resolve instances of B when loading an instance of A. It never uses the second level cache, and (because presumably I don't have cacheable control over the query submitted by Hibernate to eagerly fetch the B referenced by an A) it never uses the query cache either.

Is that a correct assumption i.e. eagerly-fetched many-to-one references can never be resolved from the query or 2nd-level cache? Is there a way to force eager fetching to use the 2nd-level cache?

Thanks in advance,

Alan


Top
 Profile  
 
 Post subject:
PostPosted: Mon Feb 20, 2006 10:13 pm 
Expert
Expert

Joined: Thu Dec 23, 2004 9:08 pm
Posts: 2008
No. Eager means exactly that: proactively go to the database, getting as much as you need, not caring about how much effort that is.

If you want to get things from the cache sometimes, and fetch them eagerly other times, leave the mapping's lazy setting at its default, and override it on the appropriate queries.


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.