Forums Register Login

Standard Practice persistence.xml Multiple Environments

+Pie Number of slices to send: Send
I had asked a question regarding this a while back but I want to ask a more specific question. With regards to deploying to multiple environments like dev, test, stage, etc, what is the best way to handle the differences in database connection info in the persistence.xml. I can't find anything that allows me to put anything in a properties file that the persistence.xml can read.

Is it just a matter of maintaining multiple persistence file and copying the right one in on a build/deploy?
+Pie Number of slices to send: Send
 

Originally posted by Gregg Bolinger:
Is it just a matter of maintaining multiple persistence file and copying the right one in on a build/deploy?



Or maybe on similar lines, maintain one single persistence.xml file with placeholders and let Ant script does the appropriate replacements.

P.S: In JBoss, you can specify properties like ${my.database.name} in the persistence.xml and then pass a -Dmy.database.name=MyDB as a JVM option. JBoss will replace these placeholders with the values passed as system properties. I don't think this is available in standalone JPA.
When people don’t understand what you are doing they call you crazy. But this tiny ad just doesn't care:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com


reply
reply
This thread has been viewed 1727 times.
Similar Threads
Problem in config. JPA in JBOSS
JPA - inject of EntityManager is always null
Hibernate and Persistence.xml
Accessing multiple databases with JPA
Is persistence.xml required
More...

All times above are in ranch (not your local) time.
The current ranch time is
Mar 28, 2024 10:30:35.