1

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.

1 Answer 1

2

This example shows you an example to integrate Spring + Hibernate + EHCache.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.