Issue
I want to set the values of my persistence.xml file with the values from my properties.config.
Is there any way to do this? Like any buildin function?
factory.setvaluesfrompersistence(config.getpropertie("name"));
I want to do this bc I don't want to set my personal values in the persistence.xml so if I deploy this version there is no sesible data in there.
I use EclipseLink as JPA Propvider
my properties.config:
db.url=
db.user=
db.psw=
and my persistens.xml:
<?xml version="1.0" encoding="UTF-8" ?>
<persistence
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd"
version="2.0" xmlns="http://java.sun.com/xml/ns/persistence">
<persistence-unit name="test"
transaction-type="RESOURCE_LOCAL">
<class>my.test.test</class>
<properties>
<property name="javax.persistence.jdbc.driver"
value="" />
<property name="javax.persistence.jdbc.url"
value="" />
<property name="javax.persistence.jdbc.user" value="" />
<property name="javax.persistence.jdbc.password" value="" />
</properties>
</persistence-unit>
</persistence>
How I call it:
factory = Persistence.createEntityManagerFactory(PERSISTENCE_UNIT_NAME);
final EntityManager em = factory.createEntityManager();
final Query q = em.createQuery("select b from Beruf b");
final List<Beruf> BerufeList = q.getResultList();
for (final Beruf beruf : BerufeList) {
System.out.println(beruf);
}
em.close();
Solution
Solution
Is to create a Map where you set the key from persistence.xml file and give it a new value.
Answered By - Phil
Answer Checked By - Clifford M. (JavaFixing Volunteer)