如何在spring mvc中使用ehcache和hibernate [英] how to use ehcache in spring mvc with hibernate
问题描述
我是spring-mvc的新手,希望在hibernate中集成ehcache作为二级缓存。
我按照本教程 ehcache
现在我的hibernate.xml中的条目如下:
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>
ehcache.xml中的条目如下:
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>
我们正在关注mvc模型并在模型中定义了annootation
we are following mvc model and in model i defined annootation
@Entity
@Cache(usage=CacheConcurrencyStrategy.READ_ONLY,
region="department")
现在问题是如何在服务层中开始使用此缓存。
我没有在我的项目中创建hibernateUtil.java。我们正在使用基于web的spring-hibernate mvc应用程序。
现在如何开始,我没有得到。
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.
推荐答案
这示例向您展示了集成Spring + Hibernate + EHCache的示例。
This example shows you an example to integrate Spring + Hibernate + EHCache.
这篇关于如何在spring mvc中使用ehcache和hibernate的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!