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
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: 15286
    
    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 - A Test Data Generation Platform
Jaikiran Pai
Marshal

Joined: Jul 20, 2005
Posts: 9327
    
110

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]
 
jQuery in Action, 2nd edition
 
subject: Standard Practice persistence.xml Multiple Environments
 
Similar Threads
Is persistence.xml required
Problem in config. JPA in JBOSS
Accessing multiple databases with JPA
JPA - inject of EntityManager is always null
Hibernate and Persistence.xml