基于注解形式的hibernate二级缓存的使用(ehcache)
来源:互联网 发布:客户地图制作软件 编辑:程序博客网 时间:2024/04/29 19:38
第三方插件为ehcache,spring+hibernate
基于注解形式;
我使用的是maven管理项目,需要添加的maven依赖:
<dependency> <groupId>com.googlecode.ehcache-spring-annotations</groupId> <artifactId>ehcache-spring-annotations</artifactId> <version>1.1.2</version> <type>jar</type> <scope>compile</scope> </dependency>
如果不使用依赖,直接导入包的话除了ehcache的jar包之外应该加上:common-logging,backport-util-concurrent这两个(我使用的是依赖,直接导入jar包方式没有尝试过,是看书上这么说的)
第一步:
package com.easitech.domain;@Entity@Cache(usage=CacheConcurrencyStrategy.NONSTRICT_READ_WRITE)@Table(name="tb_permission" ,catalog="crebas")public class Permission extends BaseDomain {第二步:
<bean id="sessionFactory"class="org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean"><property name="dataSource" ref="dataSource" /><property name="packagesToScan"><list><value>com.easitech.domain</value></list></property><property name="hibernateProperties"><props><!-- 1.使用EHCache缓存实现方案 --><prop key="hibernate.cache.provider_class">org.hibernate.cache.EhCacheProvider</prop><prop key="hibernate.dialect">org.hibernate.dialect.MySQLDialect</prop><!-- 显示sql语句 --><prop key="hibernate.show_sql">true</prop></props></property><!-- 2.配置缓存策略 --><property name="entityCacheStrategies"><props><prop key="com.easitech.domain.Permission">nonstrict-read-write,fixedRegion</prop></props></property></bean>第三步:
在src下建立一个文件ehcache.xml;
<ehcache>
<diskStore path="java.io.tmpdir"/>
<defaultCache maxElementsInMemory="10000" eternal="false"
overflowToDisk="false" timeToIdleSeconds="0" timeToLiveSeconds="0"
diskPersistent="false" diskExpiryThreadIntervalSeconds="120" />
<cache name="fixedRegion" maxElementsInMemory="100"
eternal="true" overflowToDisk="false"/>
</ehcache>
这里注意timeToIdleSeconds中间一个是I一个是l,不一样的;一个是大写的i,一个是小写的L
- 基于注解形式的hibernate二级缓存的使用(ehcache)
- 基于注解形式的hibernate二级缓存的使用(ehcache)
- 基于注解形式的hibernate二级缓存的使用(ehcache)
- ehCache基于JPA的二级缓存的使用
- Hibernate二级缓存以及ehcache的搭建配置(注解方式)
- struts2+hibernate+ehcache二级缓存(注解方式)
- Hibernate的二级缓存技术 EhCache
- Hibernate使用EHCache二级缓存
- Hibernate二级缓存使用(ehcache)
- Hibernate二级缓存插件EHCache的配置
- Hibernate二级缓存以及ehcache的搭建配置
- Hibernate 的 二级缓存——ehcache配置文件
- 搭建Hibernate二级缓存EHcache的环境
- Hibernate二级缓存以及ehcache的搭建配置
- hibernate注解方式的二级缓存
- Hibernate注解方式的二级缓存
- 二级缓存的应用(ehcache)
- Hibernate使用Ehcache实心二级缓存
- 怎么用HTML语言在网页中插入FLV视频
- 推荐一系列优秀的Android开发源码
- 中文分词器扩充中文词库IKAnalyzer
- C++中struct与class的区别是什么?
- Java中堆(heap)和栈(stack)的区别
- 基于注解形式的hibernate二级缓存的使用(ehcache)
- java常用正则表达式
- CSS3实现DIV圆角完整代码
- 自动挂载NFS目录的两个办法
- Eclipse插件
- iis设置Gzip后,无后缀的url无法压缩解决
- delphi中使用mapx想用鼠标滚轮实现自定义倍率的缩放,并且限制一定的缩放倍数
- Linux 信号signal处理函数
- tar 基本操作