Skip to content

Commit

Permalink
feat: allow overriding of persistence properties
Browse files Browse the repository at this point in the history
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.

[1] https://openjpa.apache.org/builds/1.0.2/apache-openjpa-1.0.2/docs/manual/ref_guide_conf_specify.html
  • Loading branch information
Wanja Zaeske committed Jan 29, 2024
1 parent c85217b commit 809037c
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion app/jpa/manager/impl/HibernateManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 809037c

Please sign in to comment.