-->
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.  [ 1 post ] 
Author Message
 Post subject: Native query & second-level cache problem
PostPosted: Thu Jun 25, 2009 11:02 pm 
Newbie

Joined: Thu Jan 24, 2008 9:38 pm
Posts: 2
Here is the scenario,

We have an entity, which is the result of a native query, joining 3 tables together. We have query cache as well as second level cache enabled. We are testing the timeToLiveInSeconds attribute. Every 15 minutes, we want the cache to refresh. But for testing purposes we've set this attribute to 5s and running multiple sequential queries over and over.

What we see is,
1) first hit - not in cache, hit the database and cache results
2) second hit - IS in cache - ok, return cached results
3) third hit - IS in cache, but expired (TTL expired), so ehcache returns null
* This is where the problem occurs. The symptom is "table does not exist"
* Looking at the query hibernate tries to run when it attempts to loadFromDatasource = it's not using the native query at all, it's making assumptions on the mapping strategy. IE: hibernate creates a very simple HQL query that selects all the properties from the entity, which obviously does not work as each property is the result of a native query joining multiple tables.
* After some digging through source code, I notice that when hibernate tries to load from datasource, it's gets a persister that is a "SingleTablePersister", I believe the default.
? How can I get it to reload from the NativeQuery as defined in the @Entity? Am I using something incorrectly?

Has anyone run into this before? We are at a loss, and are about to implement our own caching - which is unfortunate we would have liked to use hibernate / ehcache.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

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.