This week's book giveaway is in the Artificial Intelligence forum.
We're giving away four copies of Pragmatic AI and have Noah Gift on-line!
See this thread for details.
Win a copy of Pragmatic AI this week in the Artificial Intelligence forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Jeanne Boyarsky
  • Liutauras Vilda
  • Campbell Ritchie
  • Tim Cooke
  • Bear Bibeault
Sheriffs:
  • Paul Clapham
  • Junilu Lacar
  • Knute Snortum
Saloon Keepers:
  • Ron McLeod
  • Ganesh Patekar
  • Tim Moores
  • Pete Letkeman
  • Stephan van Hulst
Bartenders:
  • Carey Brown
  • Tim Holloway
  • Joe Ess

hibernate query cache  RSS feed

 
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

 
Consider Paul's rocket mass heater.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!