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
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
蕃薯耀 2013年8月24日 11:53:28 星期六

本文介绍了如何在Hibernate中配置和使用二级缓存。主要包括添加ehcache.xml配置文件、配置hibernate.cfg.xml启用二级缓存并指定缓存提供者,以及为特定实体类启用缓存。此外还提到了需要添加commons-logging库来避免运行时错误。
4189

被折叠的 条评论
为什么被折叠?



