一级缓存:
当应用程序调用Session 的save() 、update() 、savaeOrUpdate() 、get() 或load() ,以及调用查询接口的list() 、iterate() 或filter() 方法时,如果在Session 缓存中还不存在相应的对象,hibernate配置文件中添加:

 

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

2.在要缓存的数据的实体配置文件中 添加:

<cache usage="read-only"/>

3.在查询dao中查询语句中添加

this.getHibernateTemplate().setCacheQueries(true);

4.添加ehcache.xml

相关文章:

  • 2021-05-30
  • 2021-09-26
猜你喜欢
  • 2021-09-05
  • 2021-05-22
  • 2021-10-04
  • 2021-07-24
相关资源
相似解决方案