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: Query Cache misses and @Inheritance
PostPosted: Tue May 18, 2010 1:48 pm 
Newbie

Joined: Wed Oct 20, 2004 3:05 pm
Posts: 3
I'm in the process of setting up query caching for a web application, and I'm noticing that all of my HQL queries that include @Inheritance annotated Entities (and subclasses) never result in a cache hit. However, HQL queries that reference normal entities do result in cache hits.

Looking at the debug statements, EhCache uses the same sql key for each query against the StandardQueryCache region. So, in theory, they should be hitting. In fact, the EhCache MemoryStore spits out a message indicating a hit.
Code:
DEBUG net.sf.ehcache.store.MemoryStore  - org.hibernate.cache.StandardQueryCacheCache: org.hibernate.cache.StandardQueryCacheMemoryStore hit for sql:  select blah blah blah...

Unfortunately, the Hibernate statistics indicate otherwise. For a simple HQL query "FROM InheritanceBean o" that's executed 5 times, I get the following stats:
Code:
QueryCachePutCount = 5
QueryCacheHitCount = 0
QueryCacheMissCount = 5

But for "FROM NormalBean o" that's executed 5 times, I get the following stats:
Code:
QueryCachePutCount = 1
QueryCacheHitCount = 4
QueryCacheMissCount = 1

Has anyone seen this behavior before or, better yet, can explain why this is happening and how to get around it? Has anyone tried to set up query caching on inheritance mapped Entities before? Any help would be greatly appreciated. Thanks!

Steve

- Using Hibernate 3.5.2, EhCache 1.5.0 (with no custom ehcache.xml settings), Spring Framework 3.0.1.RELEASE-A (HibernateTemplate with setCacheQueries set to true) with single table inheritance.


Top
 Profile  
 
 Post subject: Re: Query Cache misses and @Inheritance
PostPosted: Mon Sep 06, 2010 4:56 pm 
Newbie

Joined: Mon Sep 06, 2010 4:52 pm
Posts: 1
I have got the same issue with inheritance and 2nd level cache, it seems that these entities aren't cached at all.

Have you fixed this issue?


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.