javafan

hibernate二级缓存

第一步:添加二级缓存配置文件ehcache.xml到项目的src目录

    ehcache.xml文件可以在hibernate-release-4.2.4.Final\project\etc目录下找到

 

第二步:配置hibernate.cfg.xml文件

1、首先添加二级缓存支持:

<property name="cache.use_second_level_cache">true</property>

 

2、添加二级缓存服务提供类:

<property name="cache.provider_class">org.hibernate.cache.EhCacheProvider</property>

 

3、添加需要用到二级缓存的类

<class-cache usage="read-only" class="com.study.bean.Student"/>

 

第三步:添加commons-logging-1.1.3.jar,不然会报错下载地址:http://apache.dataguru.cn//commons/logging/binaries/commons-logging-1.1.3-bin.zip

 

 

posted on 2013-08-24 12:06 明天的明天 阅读(1373) 评论(0)  编辑  收藏


只有注册用户登录后才能发表评论。


网站导航: