Win a copy of Learn Spring Security (video course) this week in the Spring forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

openjpa question

 
triyoggg Reddy
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 17278
6
IntelliJ IDE Mac Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
triyoggg Reddy
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 17278
6
IntelliJ IDE Mac Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic