• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Standard Practice persistence.xml Multiple Environments

 
Gregg Bolinger
GenRocket Founder
Ranch Hand
Posts: 15302
6
Chrome IntelliJ IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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?
 
Jaikiran Pai
Marshal
Pie
Posts: 10444
227
IntelliJ IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic