-->
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: SQL Query cache always out of date
PostPosted: Sun Feb 25, 2007 2:07 pm 
Newbie

Joined: Sat Feb 24, 2007 8:40 am
Posts: 4
NHibernate 1.2.0.2003
I'm trying to use second level cache for caching HQL queries in a web application. My query looks like this:

IList List<Child> = session.CreateQuery("from Child c where c.Parent.Id = :id order by c.Id )
.SetInt32("id",1)
.SetCacheable(True)
.SetCacheRegion("Main")
.List<Child>();


Both Parent and Child have a <cache usage="read-write" /> in their xml files.

Following properties in the nHibernate configuration files (I am using the sessionfactory for multiple databases):

<property name="hibernate.prepare_sql">false</property>
<property name="hibernate.cache.provider_class">NHibernate.Caches.SysCache.SysCacheProvider, NHibernate.Caches.SysCache</property>
<property name="hibernate.cache.use_query_cache">true</property>
<property name="hibernate.use_reflection_optimizer">false</property>
<property name="relativeExpiration">300</property>


When I look at the logging (and SQL server trace), I can see that second level cache is working for indiviual entities when they are loaded with the session.Load method.

The HQL query however, is always excuted (see select appearing in SQL Profiler).

In the logging of log4net, I always see the following log entry :cached query results were not up to date

Any idea what I'm doing wrong? What do I have to do to make this working?


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.