Uploaded image for project: 'OpenJPA'
  1. OpenJPA
  2. OPENJPA-2886

javax.persistence.schema-generation.database.action setting seems to be ignored when using Persistence.createEntityManagerFactory()

    XMLWordPrintableJSON

Details

    • Question
    • Status: Open
    • Major
    • Resolution: Unresolved
    • 3.1.2
    • None
    • jpa
    • None
    • TomEE 8.0.6 (and 8.0.9-SNAPSHOT), Netbeans 12.5, MS Windows 10

    Description

      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:

       

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

      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 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)?

       

       

       

      Attachments

        Activity

          People

            Unassigned Unassigned
            Makkus Makkus B.
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated: