gpt4 book ai didi

java - 如何在 persistence.xml 中设置默认的 Eclipselink CacheCooperativeType?

转载 作者:太空宇宙 更新时间:2023-11-04 10:11:19 40 4
gpt4 key购买 nike

如果您查看此页面: http://www.eclipse.org/eclipselink/documentation/2.4/jpa/extensions/a_cache.htm

它的内容如下:

(Optional) Set this attribute to the cache coordination mode (org.eclipse.persistence.annotations.CacheCoordinationType enumerated type). You must also configure cache coordination in your persistence unit properties. See "Caching".

我无法确定要设置什么属性,因为引用的文档没有提供示例。我尝试了这个,但出现了异常:

<property
name="eclipselink.cache.type.coordinationType"
value="INVALIDATE_CHANGED_OBJECTS" />

Sep 10 22:57:15 apps-3 run.sh[24742]:  java.lang.IllegalArgumentException: Property eclipselink.cache.type.coordinationType has an illegal value INVALIDATE_CHANGED_OBJECTS.
Sep 10 22:57:15 apps-3 run.sh[24742]: #011at org.eclipse.persistence.internal.sessions.PropertiesHandler$Prop.getValueToApply(PropertiesHandler.java:366)
Sep 10 22:57:15 apps-3 run.sh[24742]: #011at org.eclipse.persistence.internal.sessions.PropertiesHandler$Prop.getPrefixValuesToApply(PropertiesHandler.java:322)
Sep 10 22:57:15 apps-3 run.sh[24742]: #011at org.eclipse.persistence.internal.sessions.PropertiesHandler.getPrefixValuesLogDebug(PropertiesHandler.java:155)
Sep 10 22:57:15 apps-3 run.sh[24742]: #011at org.eclipse.persistence.internal.jpa.EntityManagerSetupImpl.updateDescriptorCacheSettings(EntityManagerSetupImpl.java:1424)
Sep 10 22:57:15 apps-3 run.sh[24742]: #011at org.eclipse.persistence.internal.jpa.EntityManagerSetupImpl.updateSession(EntityManagerSetupImpl.java:2729)
Sep 10 22:57:15 apps-3 run.sh[24742]: #011at org.eclipse.persistence.internal.jpa.EntityManagerSetupImpl.deploy(EntityManagerSetupImpl.java:713)
Sep 10 22:57:15 apps-3 run.sh[24742]: #011at org.eclipse.persistence.internal.jpa.EntityManagerFactoryDelegate.getAbstractSession(EntityManagerFactoryDelegate.java:207)
Sep 10 22:57:15 apps-3 run.sh[24742]: #011at org.eclipse.persistence.internal.jpa.EntityManagerFactoryDelegate.createEntityManagerImpl(EntityManagerFactoryDelegate.java:307)
Sep 10 22:57:15 apps-3 run.sh[24742]: #011at org.eclipse.persistence.internal.jpa.EntityManagerFactoryImpl.createEntityManagerImpl(EntityManagerFactoryImpl.java:337)
Sep 10 22:57:15 apps-3 run.sh[24742]: #011at org.eclipse.persistence.internal.jpa.EntityManagerFactoryImpl.createEntityManager(EntityManagerFactoryImpl.java:318)
Sep 10 22:57:15 apps-3 run.sh[24742]: #011at org.apache.openejb.assembler.classic.ReloadableEntityManagerFactory.createEntityManager(ReloadableEntityManagerFactory.java:208)

有人知道该怎么做吗?谢谢!

最佳答案

我想我应该为其他正在寻找的人添加答案:

我们添加了以下 PU 属性,并且缓存效果非常好!我们在 Apache TomEE 上运行,因此如果您在其他应用服务器上,下面的 openejb:Resource/jms/connectionFactory 值将会有所不同

        <property
name="eclipselink.cache.coordination.protocol"
value="jms" />
<property
name="eclipselink.cache.coordination.jms.topic"
value="openejb:Resource/com.xxx.applications.eclipselink.cache" />
<property
name="eclipselink.cache.coordination.jms.factory"
value="openejb:Resource/jms/connectionFactory" />
<property
name="eclipselink.cache.coordination.jms.reuse-topic-publisher"
value="true" />
<property
name="eclipselink.cache.coordination.remove-connection-on-error"
value="true" />
<property
name="eclipselink.session.name"
value="com.xxx.xxx-jpa-model" />

关于java - 如何在 persistence.xml 中设置默认的 Eclipselink CacheCooperativeType?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52266574/

40 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com