rxue / dictionary-jpa

This is your repo dictionary-jpa
https://github.com
0 stars 0 forks source link

Remove existing persistence.xml and make the location of persistence.xml configurable outside the scope of the jar when running the Main #4

Closed rxue closed 1 month ago

rxue commented 1 month ago

Original intention of this task is to bootstrapping JPA app in Java SE envrionement with with Persistence.createEntityManagerFactory(String persistenceUnitName, Map properties) or Persistence.generateSchema(String persistenceUnitName, Map properties) with an inexistent peristent unit, say the persistence unit with the given persistenceUnitName is thought to be generated when invoking those methods mentioned above

Conclusion

But my thought is wrong since JPA spec stated:

A persistence unit is defined by a persistence.xml file

=> the easiest way should be to keep the META-INF/persistence.xml in the jar so that there is at least an existing persistence unit with a defined persistence provider and other properties can be replaced by the Map properties in Persistence.createEntityManagerFactory(String persistenceUnitName, Map properties) and Persistence.generateSchema(String persistenceUnitName, Map properties)