• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

JPA/Hibernate: Selecting data from second database?

 
André-John Mas
Ranch Hand
Posts: 37
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have two databases that I need to access from my application. They are both part of the same MySQL instance. While I can connect to the database that I declared in the connection, I am not sure what they best way of accessing the second database is. Can anyone advise me on the best way to do this?
 
Bhagat Singh Rawat
Ranch Hand
Posts: 93
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
André-John Mas wrote:I have two databases that I need to access from my application. They are both part of the same MySQL instance. While I can connect to the database that I declared in the connection, I am not sure what they best way of accessing the second database is. Can anyone advise me on the best way to do this?



As Hibernate suggests that


SessionFactory instances are not lightweight and typically one instance is created for the whole application. If the application accesses multiple databases, it needs one per database.


You need to create two SessionFactory for each database.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic