Makkus B. created OPENJPA-2886:
----------------------------------

             Summary: javax.persistence.schema-generation.database.action 
setting seems to be ignored when using Persistence.createEntityManagerFactory()
                 Key: OPENJPA-2886
                 URL: https://issues.apache.org/jira/browse/OPENJPA-2886
             Project: OpenJPA
          Issue Type: Question
          Components: jpa
    Affects Versions: 3.1.2
         Environment: TomEE 8.0.6 (and 8.0.9-SNAPSHOT), Netbeans 12.5, MS 
Windows 10
            Reporter: Makkus B.


As I'm very new to OpenJPA I'm not quite sure, if this the follwing is an 
OpenJPA issue but I obeserve that:

When creating a persistence unit via persistence.xml (Tomee 8) openJPA creates 
missing entity tables according to the 
javax.persistence.schema-generation.database.action property. However, Im 
currently testing a 'runtime' datasource configuration like this:

 
{code:java}
Properties props = new Properties();
        props.put("javax.persistence.jtaDataSource", "jdbc/dynamicDb");
        props.put("openjpa.ConnectionDriverName", "org.mariadb.jdbc.Driver");
        props.put("openjpa.ConnectionURL", 
"jdbc:mariadb://localhost:3306/test");
        props.put("javax.persistence.schema-generation.database.action", 
"create");
        EntityManagerFactory factory = 
Persistence.createEntityManagerFactory("test-unit3", props);
        return factory.createEntityManager();{code}
When caling persist() on the created EntityManager I get a rollback excpetion 
due to  missing database tables although 
javax.persistence.schema-generation.database.action is given as "create". When 
debugging I can see, that the 
javax.persistence.schema-generation.database.action property on value is 0.

Two questions:

a) It what I am doing a legal way to create an entity manager at all?

b) Why are no tables created in this case ( but are when using the 
persitence.xml)?

 

 

 



--
This message was sent by Atlassian Jira
(v8.20.1#820001)

Reply via email to