0

我有一个非常小的测试,可以正确配置 openJPA、JTA、数据库连接、增强并且不发出异常,但是它不会与下面的简单代码一起存在。除了将记录实际写入数据库的简单语句之外,我还需要显示什么或需要什么?

public class Manipulation00 {
    public Manipulation00(){}
    public void startUp(ServletContext sc){
                EntityManagerFactory emf =
           (EntityManagerFactory)sc.getAttribute("emf");
        EntityManager em = emf.createEntityManager();
        Exemptions00 exempt00 = new Exemptions00();
        exempt00.setUpc("722430001166");
        exempt00.setDesc("KOMBUCHA,OG2,SEASONAL");
        em.persist(exempt00);
    }

}

持久性.xml

<?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="ediExemptions" transaction-type="JTA">
        <provider>org.apache.openjpa.persistence.PersistenceProviderImpl</provider>
        <jta-data-source>java:app/ediExemptions</jta-data-source>
        <class>tng.db02.Exemptions00</class>
        <properties>
            <property name="javax.persistence.schema-generation.database.action" value="drop-and-create"/>
            <property name="openjpa.Log" value="DefaultLevel=WARN, Tool=INFO"/>
            <property name="openjpa.jdbc.SynchronizeMappings"
                      value="buildSchema"/>
            <property name="openjpa.ConnectionURL"
                      value="jdbc:derby://localhost:1527/ediExemptions"/>
            <property name="openjpa.ConnectionDriverName"
                      value="org.apache.derby.jdbc.ClientDriver"/>
            <property name="openjpa.ConnectionUserName"
                      value="root"/>
            <property name="openjpa.ConnectionPassword"
                      value="admin"/>
        </properties>
    </persistence-unit>
</persistence>
4

1 回答 1

0

我猜你的交易没有被提交。

于 2017-08-14T16:27:54.827 回答