Reputation: 55
I am new to spring-mvc and want to integrate ehcache as second level cache in hibernate. I followed this tutorial ehcache Now entries in my hibernate.xml are as follows:
<property name="hibernate.cache.region.factory_class" value="org.hibernate.cache.ehcache.SingletonEhCacheRegionFactory"/>
<property name="hibernate.cache.use_second_level_cache" value="true"/>
<property name="hibernate.cache.use_query_cache">true</property>
<property name="hibernate.cache.provider_configuration_file_resource_path">ehcache.xml</property>
<property name="hibernate.generate_statistics">true</property>
entries in ehcache.xml are as follows:
<ehcache xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="http://ehcache.org/ehcache.xsd">
<diskStore path="java.io.tmpdir"/>
<!--defaultCache
eternal="false"
maxElementsInMemory="1000"
maxElementsOnDisk="10000"
overflowToDisk="true"
diskPersistent="true"
timeToLiveSeconds="300"
statistics="true"
copyOnWrite="true"
/-->
<cache name="com.payupaisa.cms.model.Event"
maxElementsInMemory="100000"
eternal="true"
overflowToDisk="false"
memoryStoreEvictionPolicy="LFU"
statistics="true"
timeToLiveSeconds="3600"
/>
</ehcache>
we are following mvc model and in model i defined annootation
@Entity
@Cache(usage=CacheConcurrencyStrategy.READ_ONLY,
region="department")
Now issue is how to start using this cache in service layer. I have not created hibernateUtil.java in my project. we are having web based spring-hibernate mvc application. Now how to start , i am not getting.
Upvotes: 1
Views: 4966
Reputation: 89189
This example shows you an example to integrate Spring + Hibernate + EHCache.
Upvotes: 2