Hi All,
I am using Spring 2.0 and hibernate 3.1 in our project. In my project home page occupying the 6Mb size in 3 select queries. So I want place that 6Mb in cache with that i can reduce the database hits.
I knew that hibernate provides secondary level cache by using
ehCache.xml.
I did the following:
1. Placed ehcache.xml in myproject.
<defaultCache
maxElementsInMemory="10000"
eternal="false"
timeToIdleSeconds="120"
timeToLiveSeconds="120"
overflowToDisk="true"
/>
<cache name="com.sa.intranet.model.businessobject.SaPostingCategoryMaster"
maxElementsInMemory="50"
eternal="false"
timeToIdleSeconds="300"
timeToLiveSeconds="600"
overflowToDisk="true"
/>
<!-- Sample cache named sampleCache2
This cache contains 1000 elements. Elements will always be held in memory.
They are not expired. -->
<cache name="com.sa.intranet.model.businessobject.SaPraisewallMaster"
maxElementsInMemory="50"
eternal="true"
overflowToDisk="false"
/>
2. In Both SaPraisewallMastern and SaPostingCategoryMaster hbm files, i placed
<cache usage="read-only"/>
3.
Configuration of in applicationConfig.xml
<prop key="hibernate.c3p0.use_sql_comment">true</prop>
<prop key="hibernate.c3p0.generate_statistics">
true
</prop>
<prop key="hibernate.cache.use_structured_entries">
true
</prop>
Thats it.
with the above configuration i am getting exception:
Code:
Caused by: org.hibernate.cache.NoCachingEnabledException: Second-level cache is not enabled for usage [hibernate.cache.use_second_level_cache | hibernate.cache.use_query_cache]
at org.hibernate.cache.NoCacheProvider.buildCache(NoCacheProvider.java:21)
at org.hibernate.cache.CacheFactory.createCache(CacheFactory.java:61)
... 41 more
Can you help me how to follow
preceding steps and how to test whether data is storing in cache or not
Regards,
Ravi Gonella