posted 15 years ago
Hi All,
I have configured hibernate query cache in my app. I want to use the query cache for one specific part of the application where in there is heavy database roundtrip. The query in question is SQL query (not HQL due to union clause) and is accessed a lot many times during one application flow.
We wanted to utilise queryCache for this scenario so accordingly we configured the hibernate cfg xml files
---------------------------
<property name="hibernate.cache.use_second_level_cache">true</property>
<property name="hibernate.cache.use_query_cache">true</property>
<property name="cache.provider_configuration_file_resource_path">ehcache.xml</property>
<property name="hibernate.cache.provider_class">net.sf.ehcache.hibernate.EhCacheProvider</property>
---------------------------
The ehcache.xml looks like this
-------------------------
<ehcache>
<diskStore path="user.dir"/>
<defaultCache
maxElementsInMemory="10000"
eternal="false"
overflowToDisk="false"
timeToIdleSeconds="300"
timeToLiveSeconds="300"
diskPersistent="false"
diskExpiryThreadIntervalSeconds="120"
memoryStoreEvictionPolicy="LRU"/>
<cache name="org.hibernate.cache.StandardQueryCache"
maxElementsInMemory="100"
eternal="false"
timeToIdleSeconds="120"
timeToLiveSeconds="120"
overflowToDisk="false"/>
<cache name="org.hibernate.cache.UpdateTimestampsCache"
maxElementsInMemory="5000"
timeToIdleSeconds="120"
timeToLiveSeconds="120"
eternal="true"/>
</ehcache>
--------------------------------------------------------
Also i have configured the hbm xml files with <class name="com.one.two.pakgname.hib.Xtable" table="XTABLE">
<cache usage="read-only"/>
What I want to achieve is cache the data fetched by the queries. But time and again for every request I see the hibernate doing database roundtrips. I don't see the querycache getting into action at all.
Let me know your thoughts on this.
-M