问题
I need to use multiply persistence units with different properties (in my case MySQL and Oracle database). In persistence.xml I define two different "persistence-unit"s and list only the entity classes there.
Properties could be set in persitence.xml with
<properties>
<property name="..." value="..." />
...
Im doing it in a java class before creating the EntityManager, because I must use different properties (which I read before):
EntityManagerFactory factory;
...
HashMap<String, String> dbProperties = new HashMap<String, String>();
dbProperties.put("javax.persistence.jdbc.driver", driver);
dbProperties.put("javax.persistence.jdbc.url", url);
dbProperties.put("javax.persistence.jdbc.user", user);
dbProperties.put("javax.persistence.jdbc.password", password);
dbProperties.put("eclipselink.ddl-generation", "none");
dbProperties.put("eclipselink.ddl-generation.output-mode", "database");
factory = Persistence.createEntityManagerFactory(PERSISTENCE_UNIT_NAME, dbProperties);
EntityManager em = factory.createEntityManager();
...
For Oracle I need to set Schema dynamicly (if possible) and not hardcoded in @Table annotation in each Entity class. And I guess there will be other properties I need to set. So my question is: is there a way I can find all avaible properties for the EntityManager?
回答1:
You may find standard JPA properties on the corresponding JSR. For JPA 2.1 (JSR 338), you will find them on chapter 8.2.1.9 of the document. You can download the document there.
For implementation specific properties, you may find them on the documentation of the implementation you use. For EclipseLink, which seems to be the implementation you are using, you will find them there.
来源:https://stackoverflow.com/questions/34178886/is-it-possible-to-find-all-available-entitymanager-properties