Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Accessing multiple databases with JPA

 
Saathvik Reddy
Ranch Hand
Posts: 228
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I am trying to access multiple databases from an enterprise application. How to configure the persistance unit if i have to access multiple databases.

Can i have multiple persistence units in the persistence.xml file.

Please suggest me on this.

Thanks,
Srikanth.
 
Jaikiran Pai
Marshal
Pie
Posts: 10444
227
IntelliJ IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Srikanth Reddy:
Hi,

I am trying to access multiple databases from an enterprise application. How to configure the persistance unit if i have to access multiple databases.


You can configure each persistence unit to use one database. So if you have multiple databases, you can configure the corresponding number of persistence units.

Originally posted by Srikanth Reddy:

Can i have multiple persistence units in the persistence.xml file.



As per the xsd http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd, yes you can have multiple persistence units in a single xml file.
 
Saathvik Reddy
Ranch Hand
Posts: 228
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks a lot.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic