问题:使用 infinispan EmbaddedCache 更新的实体未反映在数据库中:场景:
Infinispan 版本:8.1 JDK 8
使用 id、name 属性创建了 TestEntity 类,使用 persistence.xml 配置了 OGM,在 infinispan-config.xml 中配置了 jpa-store。Infinispan 缓存从数据库加载数据,并在调用 cache.put(..) 时将实体持久保存在数据库中。代码如下。
持久性.xml:
<persistence xmlns="http://java.sun.com/xml/ns/persistence"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd"
version="2.0">
<persistence-unit name="ogm-jpa" transaction-type="JTA">
<provider>org.hibernate.ogm.jpa.HibernateOgmPersistence</provider>
<properties>
<property name="hibernate.transaction.jta.platform"
value="org.hibernate.service.jta.platform.internal.JBossStandAloneJtaPlatform" />
<property name="hibernate.ogm.datastore.provider"
value="infinispan" />
</properties>
</persistence-unit>
<persistence-unit name="CachePersistenceUnit" transaction-type="RESOURCE_LOCAL">
<provider>org.hibernate.ejb.HibernatePersistence</provider>
<class>org.infinispan.persistence.jpa.impl.MetadataEntity</class>
<!-- <class>com.scb.hws.entity.TlPymtDetails</class> -->
<properties>
<property name="javax.persistence.jdbc.url" value="..."/>
<property name="javax.persistence.jdbc.user" value="..."/>
<property name="javax.persistence.jdbc.password" value="..."/>
<property name="javax.persistence.jdbc.driver" value="oracle.jdbc.driver.OracleDriver"/>
<property name="hibernate.show_sql" value="true"/>
<property name="hibernate.format_sql" value="true"/>
</properties>
</persistence-unit>
</persistence>
infinispan-config.xml:
<local-cache name="default">
<persistence passivation="false">
<jpa-store xmlns="urn:infinispan:config:store:jpa:8.0"
shared="true" preload="true"
persistence-unit="CachePersistenceUnit"
entity-class="TestEntity"
singleton="false"
batch-size="1">
</jpa-store>
</persistence>
</local-cache>
每当从 OGM 中持久化实体时,数据都会反映在 infinispan 缓存中,但不会反映在数据库中。如何解决问题?