allow overriding of persistence properties with system properties
See https://github.com/Systems-Modeling/SysML-v2-API-Services/pull/109/commits/809037cff1d6124e3ae1ca9811f5c16c63bf9eb3
Prior to this change, the only way to change the persistence settings
was to edit the persistence.xml. In case of a pre-build .jar, the
persistence.xml has to be contained in the .jar with the persistence
module [1], and can not be overridden. However, the current repo
hard-codes the DB connection details in the persistence.xml, which
makes it impossible to override the DB connection details for a fully
built .jar without changing that .jar file.
This change enable the overriding of the properties used for the JPA
EntityManagerFactory with system properties, so that DB connection
details can be altered without changing the .jar file.
diff --git a/app/jpa/manager/impl/HibernateManager.java b/app/jpa/manager/impl/HibernateManager.java
index 793d29c..bf8df83 100644
--- a/app/jpa/manager/impl/HibernateManager.java
+++ b/app/jpa/manager/impl/HibernateManager.java
@@ -38,7 +38,8 @@ public class HibernateManager implements JPAManager {
private final EntityManagerFactory entityManagerFactory;
public HibernateManager() {
- entityManagerFactory = Persistence.createEntityManagerFactory(PERSISTENCE_UNIT_NAME);
+ entityManagerFactory = Persistence.createEntityManagerFactory(PERSISTENCE_UNIT_NAME,
+ System.getProperties());
}
@Override