【发布时间】:2011-12-03 12:57:53
【问题描述】:
所有, 是否可以在我的持久性 xml 文件中禁用二级缓存? 我有一个使用 ehcache 的 Spring+Hibernate+JPA 配置。在我的 persistence.xml 文件中,我有这个条目:
<property name="hibernate.cache.use_second_level_cache" value="false"/>
但这似乎不起作用,我仍然看到加载的实体数量不断增加,因为我的应用程序运行。我使用这个来获取统计信息:
EntityManagerFactoryInfo emfi = (EntityManagerFactoryInfo) entityManagerFactory;
EntityManagerFactory emf = emfi.getNativeEntityManagerFactory();
EntityManagerFactoryImpl empImpl = (EntityManagerFactoryImpl)emf;
log.debug(empImpl.getSessionFactory().getStatistics());
请帮忙。
【问题讨论】:
-
您在查看哪些统计信息?因为这个属性应该为所欲为,加载的实体数量与二级缓存无关。查看Statistics中所有以getSecondLevelCache开头的方法
-
我正在查看以下统计信息:“entities loaded=30”
-
加载的实体数是会话中加载的实体数,即一级缓存。
标签: hibernate spring web-applications ehcache second-level-cache