wood burning stoves 2.0*
The moose likes Object Relational Mapping and the fly likes hibernate query cache Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Databases » Object Relational Mapping
Bookmark "hibernate query cache" Watch "hibernate query cache" New topic
Author

hibernate query cache

Mohit Sinha
Ranch Hand

Joined: Nov 29, 2004
Posts: 125
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

 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
 
subject: hibernate query cache
 
Similar Threads
Renamed "ehcache.xml" to "myehcache.xml" - Cannot find the declaration of element 'ehcache'
Cache Configuration problem
ehcache.xml file I have in my ejb app is not used
Hibernate Query Cache
ehcache1.5 -Can I remove "defaultCache"? Can I have "ehcache.xml" in 2 Proj, where 1 reference other