• Post Reply Bookmark Topic Watch Topic
  • New Topic

hibernate query cache

 
Mohit Sinha
Ranch Hand
Posts: 125
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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

 
my overalls have superpowers - they repel people who think fashion is important. Tiny ad:
the new thread boost feature brings a LOT of attention to your favorite threads
https://coderanch.com/t/674455/Thread-Boost-feature
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!