Hi,
I am trying to implement caching in Hibernate. I want to use EHCache (which comes as default with Hibernate). Since it comes as default with Hibernate, in the hibernate.cfg.xml file I am only setting the following tag to enable second level caching.
Code:
<property name="hibernate.cache.use_second_level_cache">true</property>
(As you can see, I am not defining net.sf.hibernate.cache.EhCacheProvider since I am assuming that it is already set as default ...
am I wrong to assume this?.
I then created the ehcache.xml file in my root. Here I defined the attributes as follows:
Code:
<ehcache>
<defaultCache
maxElementsInMemory="10000"
eternal="true"
overflowToDisk="true"
/>
<cache name="com.myapp.common.impl.BaseCountry"
maxElementsInMemory="10000"
/>
</ehcache>
Finally I set the the cache option in the Country.hbm.xml file as follows:
Code:
<cache usage="read-write" />
Now when how do I know if caching is working or not. The time taken seem to be the same. Also I can see the Sql be generated on the screen. Does this mean that caching is not woring for me (I did something wrong int he configuration). Also to retrieve the objects I am using the Hibernate Criteria object. Does this need a different Caching options?
thanks in advance for any comments.