Dear All,
I followed the following steps while caching
1. Download ehcache.jar and put it in your classpath
2. In hibernate.cfg.xml, declare ehcache as your cache provider using the hibernate.cache.provider_class property (hibernate.cache.provider_class=org.hibernate.cache.EhCacheProvider). If you use spring, set the property in the 'hibernateProperties' of the session factory declaration.
3. In your hbm file, declare caching as follow :
<class
name="eg.MyClass"
table="MY_TABLE"
mutable="false"
>
<cache usage="read-only" />
.....
</class>
or
<class
name="eg.MyClass"
table="MY_TABLE"
>
<cache usage="read-write" />
.....
</class>
4. Create ehcache.xml in your classpath and write some cache region :
<ehcache>
<diskStore path="java.io.tmpdir"/>
<defaultCache
maxElementsInMemory="0"
eternal="false"
timeToIdleSeconds="0"
timeToLiveSeconds="0"
overflowToDisk="false"
diskPersistent="false"
diskExpiryThreadIntervalSeconds="0"
memoryStoreEvictionPolicy="LFU"
/>
<cache name="eg.MyClass"
maxElementsInMemory="25"
eternal="false"
timeToIdleSeconds="86400"
timeToLiveSeconds="86400"
overflowToDisk="false"
memoryStoreEvictionPolicy="LFU"
/>
</ehcache>
After deploying on .data file is created in the C:\Winnt\Temp.
But it's size is only 0(Zero) bytes.
May I know is this Correct or not?
Please Help.
_________________ New to Hibernate
|