我正在尝试构建一个可以使用Spring Boot持久化JPA和Mongo实体的应用程序。我已经用XAResource实现了MongoResourceManager和JPAResourceManager。 除非显式调用entityManager.flush(),否则JPAResourceManager将不会保留数据。
JTA配置
90
JPA配置
<bean class="org.springframework.transaction.jta.JtaTransactionManager"
id="transactionManager" lazy-init="true">
<property name="transactionManager">
<bean
class="com.arjuna.ats.internal.jta.transaction.arjunacore.TransactionManagerImple" />
</property>
<property name="userTransaction">
<bean class="com.arjuna.ats.jta.UserTransaction" factory-method="userTransaction" />
</property>
</bean>
JPAResourceManager
<tx:annotation-driven proxy-target-class="true" />
<bean
class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean"
id="oracleEMForacle1" lazy-init="true" primary="true">
<property name="jpaProperties">
<props>
<prop key="hibernate.format_sql">true</prop>
<prop key ="hibernate.jdbc.batch_size">50</prop>
<prop key="hibernate.dialect">org.hibernate.dialect.Oracle12cDialect</prop>
<prop key="hibernate.transaction.jta.platform">org.hibernate.engine.transaction.jta.platform.internal.JBossStandAloneJtaPlatform
</prop>
<prop key="hibernate.flushMode">commit</prop>
<prop key="hibernate.use_sql_comments">true</prop>
</props>
</property>
<property name="jpaVendorAdapter">
<bean class="org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter">
<property name="databasePlatform" value="org.hibernate.dialect.Oracle12cDialect" />
<property name="generateDdl" value="true" />
<property name="showSql" value="false" />
</bean>
</property>
<property name="jtaDataSource">
<bean class="org.apache.commons.dbcp2.BasicDataSource">
<property name="connectionProperties"
value="password=${password};user=${username}"></property>
<property name="driverClassName" value="oracle.jdbc.driver.OracleDriver" />
<property name="url" value="${url}" />
</bean>
</property>
<property name="packagesToScan">
<array>
<value>com.test.jpa.jpaentity</value>
</array>
</property>
</bean>