【发布时间】:2014-05-14 16:23:01
【问题描述】:
在JBoss/WildFly中,配置数据源时,有一个JTA选项,默认是关闭的:
<datasource jta="false" jndi-name="java:/wt/testds" pool-name="testds" enabled="true" use-ccm="false">
...
</datasource>
现在我想使用 JTA 事务类型将此数据源与 JPA 相关联:
<?xml version="1.0" encoding="UTF-8"?>
<persistence version="2.1" xmlns="http://xmlns.jcp.org/xml/ns/persistence"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/persistence http://xmlns.jcp.org/xml/ns/persistence/persistence_2_1.xsd">
<persistence-unit name="test" transaction-type="JTA">
<jta-data-source>java:/wt/testds</jta-data-source>
</persistence-unit>
</persistence>
我是否还需要在数据源上启用 JTA?
【问题讨论】:
-
与其他答案一样,我建议将其设置为 true。我刚刚花了很多时间调试一个回滚不起作用的问题,因为它被设置为 false。详情:stackoverflow.com/questions/16897063/…
标签: jpa jboss datasource jta wildfly