【发布时间】:2017-07-04 12:04:59
【问题描述】:
我在我的 Web 应用程序的 persistence.xml 中使用以下设置(我使用 Eclipselink 2.6.4):
<properties>
<property name="eclipselink.jdbc.cache-statements" value="true" />
<property name="eclipselink.cache.query-results" value="true" />
<property name="eclipselink.ddl-generation.index-foreign-keys" value="true" />
<property name="eclipselink.logging.level" value="OFF" />
<property name="eclipselink.persistence-context.close-on-commit" value="true" />
<property name="eclipselink.persistence-context.flush-mode" value="commit" />
<property name="eclipselink.persistence-context.persist-on-commit" value="false" />
</properties>
我正在使用@Cacheable(false) 注释来防止某些实体被缓存。 @Cache 注释在 2.6.4 版本中不再起作用。
我的问题是,是否有可能在全球范围内清除缓存?让每3小时说一次?
谢谢
【问题讨论】:
-
为什么缓存注解不起作用?有关使缓存失效,请参阅 wiki.eclipse.org/EclipseLink/UserGuide/JPA/… 和 eclipse.org/eclipselink/documentation/2.5/concepts/cache006.htm
-
注释不起作用的原因与我的IDE(netbeans)有关。导入包
javax.persistence.Cache我得到一个不兼容的类型错误。我必须导入正确的包(org.eclipse.persistence.annotations)。无论如何,缓存注释不是我正在寻找的解决方案。我需要一个全球性的。有没有?谢谢 -
全局无效是什么意思,仅适用于共享缓存,在 EMF 级别。如果您有多个应用程序在运行,则可以查看缓存协调,这将允许每个应用程序侦听事件。见eclipse.org/eclipselink/documentation/2.6/concepts/cache010.htm
-
我明白,所以我必须更改每个实体,或者最好让它们都扩展一个超类,在其中定义将被继承的缓存策略。该文件非常有趣。我需要一些时间来深入了解。谢谢克里斯。
标签: java eclipselink