This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes Object Relational Mapping and the fly likes openjpa question Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Databases » Object Relational Mapping
Bookmark "openjpa question" Watch "openjpa question" New topic
Author

openjpa question

triyoggg Reddy
Greenhorn

Joined: Jun 13, 2009
Posts: 4
Hello guys, I am new to openJPA.

I have a scenario where, depending upon the server where my application is running, I need to change the settings to persistance.xml.
For eg. if its running on Server A, then it should use different database(different url), different password etc. and if the application is running on Server B then it should use different information.

And could you also tell me, which way should it be done, using datasource or simply putting properties under persistence-unit.

FYI I am using WS app. server 7 and RAD 7.5

Any type of help would be highly appreciated.

Mark Spritzler
ranger
Sheriff

Joined: Feb 05, 2001
Posts: 17249
    
    6

Usually you have multiple persistence.xml files and when you run your build you run a target for each environment. Or each developer edits their own local version of persistence.xml to match what they need. But the Integration building team changes theirs for their environment.

Mark


Perfect World Programming, LLC - Two Laptop Bag - Tube Organizer
How to Ask Questions the Smart Way FAQ
triyoggg Reddy
Greenhorn

Joined: Jun 13, 2009
Posts: 4
Thanks Mark Spritzler for your reply,

My requirement is, when the application runs, it would get the environment details i.e where it is running and use (if I am right) respective persistence unit under persistence.xml.

can't I write a Servlet that reads the server envirenment and change the persistence unit. Or there is some another good approach.
Mark Spritzler
ranger
Sheriff

Joined: Feb 05, 2001
Posts: 17249
    
    6

triyoggg Reddy wrote:Thanks Mark Spritzler for your reply,

My requirement is, when the application runs, it would get the environment details i.e where it is running and use (if I am right) respective persistence unit under persistence.xml.

can't I write a Servlet that reads the server envirenment and change the persistence unit. Or there is some another good approach.


I don't have a good solution for you, because I think that is kind of a hack, and there is something in the "requirement" that is being misinterpreted or mis-designed.

Just my opinion here.

Mark
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: openjpa question
 
Similar Threads
OpenJPA
Is is possible to get OptimisticLockException when READ COMMITTED isolation level is set at appsrv?
DBCP connection pool exhausted for OpenJPA
using OpenJPA in tomcat
Remote debugging WAS 6 and RAD 6