I want my persistence.xml to set some of its properties dynamically, to be specific:
<property name="hibernate.connection.password" value="password"/>
<property name="hibernate.connection.username" value="username"/>
I can build a class that could provide me the data I need, but I don’t know how to set the class up in a way that it works like this:
<property name="hibernate.connection.password" value="${my.clazz.pass}"/>
<property name="hibernate.connection.username" value="${my.clazz.user}"/>
I have tried to set the class up like this
public class clazz{
String pass;
String user;
public clazz(){
//do stuff to set pass and user
}
//getter/setter
}
But that does not work. I haven’t found a way here or in google, but I have seen the ${my.clazz.smth}-way several times.
So, how can I set that up? 🙂
Thanks in advance!
So, resolved this a while ago, but I still didn’t answer:
Anthony Accioly pointed me to the right direction:
I added this to my applicationContext.xml’s entityManagerFactory
The corresponding class, in this case I use hibernate:
This way the setup is done just once when starting the whole thing up, but the required data may be ‘outsourced’.
Thanks again for pointing me to the right direction!