我正在使用JTA,我的persistence.xml如下
<?xml version="1.0" encoding="UTF-8" ?>
<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_1_0.xsd" version="1.0"
xmlns="http://java.sun.com/xml/ns/persistence">
<persistence-unit name="test" transaction-type="JTA">
<provider>org.eclipse.persistence.jpa.PersistenceProvider</provider>
<jta-data-source>jdbc/testDS</jta-data-source>
<class>test.entity.Employees</class>
<exclude-unlisted-classes>true</exclude-unlisted-classes>
<properties>
<property name="eclipselink.target-server" value="OC4J"/>
<property name="javax.persistence.target-database" value="Oracle"/>
<property name="javax.persistence.logging.parameters" value="TRUE"/>
</properties>
</persistence-unit>
</persistence>
当我使用JTA时,我没有EntityTransaction。
Java代码段
Employees emp = new Employees();
emp.setEmpNumber(empPOJO.getEmpNumber());
final EntityManager em = getEntityManager();
try {
em.merge(vehicleInspection);
} finally {
if (em != null && em.isOpen()) {
em.close();
}
}
}
但是我无法在数据库中保留更改。这是因为没有提交吗?