aspose file tools*
The moose likes Object Relational Mapping and the fly likes Standard Practice persistence.xml Multiple Environments Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Databases » Object Relational Mapping
Bookmark "Standard Practice persistence.xml Multiple Environments" Watch "Standard Practice persistence.xml Multiple Environments" New topic
Author

Standard Practice persistence.xml Multiple Environments

Gregg Bolinger
GenRocket Founder
Ranch Hand

Joined: Jul 11, 2001
Posts: 15299
    
    6

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?


GenRocket - Experts at Building Test Data
Jaikiran Pai
Marshal

Joined: Jul 20, 2005
Posts: 10202
    
166

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.


[My Blog] [JavaRanch Journal]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Standard Practice persistence.xml Multiple Environments