You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@openjpa.apache.org by "Romain Manni-Bucau (Jira)" <ji...@apache.org> on 2021/11/08 12:06:00 UTC
[jira] [Commented] (OPENJPA-2886)
javax.persistence.schema-generation.database.action setting seems to be
ignored when using Persistence.createEntityManagerFactory()
[ https://issues.apache.org/jira/browse/OPENJPA-2886?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17440419#comment-17440419 ]
Romain Manni-Bucau commented on OPENJPA-2886:
---------------------------------------------
Hi [~Makkus] , have to admit I didn't spot in the spec if it is legal or not, only saw persistence.xml references, do you have some other ref? In any case, we can support it but I think it is not yet coded so you can do a PR to add this support if needed.
tip: using Persistence container api you can specify it programmatically ;)
> 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.
> Priority: Major
>
> 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 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)