Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

allow overriding of persistence properties with system properties #111

Open
wucke13 opened this issue Jan 29, 2024 · 0 comments
Open

allow overriding of persistence properties with system properties #111

wucke13 opened this issue Jan 29, 2024 · 0 comments

Comments

@wucke13
Copy link

wucke13 commented Jan 29, 2024

See 809037c

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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant