我有休眠的Ehcache 4.1.4最終的Ehcache-3.3.0.jar二級緩存配置
配置(春季3.2)用於冬眠的Ehcache
hibernate.cache.use_second_level_cache=true
hibernate.generate_statistics=true
hibernate.cache.region.factory_class=org.hibernate.cache.ehcache.EhCacheRegionFactory
我的實體
@Entity
@Table(name = "SESSION_ENTERING")
@org.hibernate.annotations.Cache(usage = CacheConcurrencyStrategy.READ_ONLY)
public class SESSION_ENTERING implements Serializable {
...
My dao
public List<SESSION_ENTERING> getSESSIONS() {
return sessionFactory.getCurrentSession().
createQuery("from SESSION_ENTERING order by id desc")
.setCacheable(true)
.list();
}
//or even this
public SESSION_ENTERING getSESSION() {
return SESSION_ENTERING)sessionFactory.getCurrentSession().get(SESSION_ENTERING.class,256l);
}
Build and Depl oy Succesfull,但是這個cacheEntries == null sessionFactory.getStatistics()。logSummary();是空的
SecondLevelCacheStatistics cacheEntries = sessionFactory.getStatistics()
.getSecondLevelCacheStatistics("");
sessionFactory.getStatistics().logSummary();