-->
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 results not found in cache (if executed after 2 min..)
PostPosted: Fri Jul 06, 2007 4:01 pm 
Newbie

Joined: Thu Jun 14, 2007 5:28 pm
Posts: 7
Hello,

Iam kind of new to Hibernate, so trying to see whats wrong with the configuration/code i have.

If i execute the query in a loop the results are fine, Iam getting all the values from cache. But when i sleep for 2 min or so and execute its executing the sqls and not getting from the cache.


Following are some of the cache logs.

15:32:24 DEBUG cache.StandardQueryCache - checking cached query results in region: UserQueryCacheRegion
15:32:24 DEBUG cache.StandardQueryCache - query results were not found in cache
15:32:25 DEBUG cache.StandardQueryCache - caching query results in region: UserQueryCacheRegion

I defined by own Query Cache region: (iam using EHcache)
<cache
name="UserQueryCacheRegion"
maxElementsInMemory="10000"
eternal="true"
timeToIdleSeconds="3600" // i tried with value 0 also
timeToLiveSeconds="3600" // i tried with value 0 also
overflowToDisk="true"
/>

The eternal is set to true and also the idle or live seconds is set to an hour. Heres my cache props:
<property name="hibernate.cache.provider_class">
org.hibernate.cache.EhCacheProvider
</property>
<property name="hibernate.cache.use_second_level_cache">true</property>
<property name="hibernate.cache.use_query_cache">true</property>

My code is like:

try {
HbSessionUtil.getSession(); //open session


String hqlQuery = "from User as user where user.userPriv.privKey=?"
Query query = session.createQuery(hqlQuery);
query.setString(1, "abc");
query.setCacheable(true);
query.setCacheRegion(HbConstants.USER_QUERY_CACHE_REGION);

...........
LogUtil.debug(CLASSNAME,
"Time taken for Hibernate transaction: "
+ (System.currentTimeMillis() - startMs));
} catch (Exception excep) {
LogUtil.debug(CLASSNAME, "Hibernate error while getting Test", excep);
throw new HbException(excep);
} finally {
HbSessionUtil.closeSession();//close session
}

I would really appreciate your help.


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jul 09, 2007 9:59 am 
Newbie

Joined: Thu Jun 14, 2007 5:28 pm
Posts: 7
seems like this is happening in the weblogic environment. I executed a stand alone and it seems to be working fine.
Can any one help.


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.