cp.
cp.

Reputation: 1271

openJPA configured not persisting

I have a very minimal test that properly configures openJPA, JTA, database connectivity, enhancement and emits no exceptions however it does not persist with the simple code below. What more do I need to show or what is necessary beyond the simple statements to actually write records to the db?

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);
    }

}

the persistence.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>

Upvotes: 0

Views: 50

Answers (1)

Rick
Rick

Reputation: 3840

I'd guess that your transaction isn't being committed.

Upvotes: 0

Related Questions