-->
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.  [ 5 posts ] 
Author Message
 Post subject: typesafe objects and caching
PostPosted: Mon Mar 06, 2006 4:07 pm 
Newbie

Joined: Wed Oct 01, 2003 8:03 pm
Posts: 6
Hi,

When the query cache is enabled, are hibernate queries involvin new'd typesafe objects cached?

i.e. if i have a query like so


select new domain.TopCustomer( member.name, member.purchasePower ) from domain.Member member where member.purchaseHorizon = 3 and member.purchasePower > 2

and i have the query cache enabled and the query set to cacheable, would new'ly created TopCustomer objects also be cached?


Top
 Profile  
 
 Post subject:
PostPosted: Mon Mar 06, 2006 10:26 pm 
Expert
Expert

Joined: Thu Dec 23, 2004 9:08 pm
Posts: 2008
The query cache doesn't cache objects, only row ids. And as there are no row ids resulting from your query, nothing will get cached.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Mar 07, 2006 12:17 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 3:00 pm
Posts: 1816
Location: Austin, TX
slight correction: the query cache only caches the ids relating to entity returns.

This is not an entity return, but a scalar return. The results here will in fact be cached.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Mar 07, 2006 12:29 am 
Expert
Expert

Joined: Thu Dec 23, 2004 9:08 pm
Posts: 2008
Cunning. I think I can make use of this new tidbit to optimize quite a few small-entity queries I have. If I "select new MappedClass(param1, param2...)", does Hibernate get excessively smart and realize that MappedClass is an entity? Because if Hibernate doesn't, and the objects (that are entities) are cached in their entirety, certain report-style queries returning small entities ("type" objects, mostly) can be cached quite efficiently using this technique..


Top
 Profile  
 
 Post subject:
PostPosted: Tue Mar 07, 2006 12:44 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 3:00 pm
Posts: 1816
Location: Austin, TX
No, only the scalar values are cached (i.e. the simple properties) and the object "wrapper" rebuilt when pulled from the cache.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 5 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.