Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Hibernate and Multi DataSource

 
Vo Hien
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Friends,
I have a problem with Hibernate and DataSource.
Currently my project is using Hibernate. The *.CFG.XML file contains information for loading ONE database from the SQL Server 2005. So, the project only can use one database.

My purpose is to use two databases in the project with the Hibernate.

Do you have any suggestion , example or solutions for this problem.

Many thanks and regards,

Hien Vo
 
Paul Sturrock
Bartender
Posts: 10336
Eclipse IDE Hibernate Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You will need to use two SessionFactories. Assuming you abstract your data access logic with a DAO layer this shouldn't be too much of an issue.
 
Susanta Chatterjee
Ranch Hand
Posts: 102
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Paul is right. We are using multiple databases (and multiple schema on same database) and for each database/schema, we have one SessionFactory. Works fine, a little complicated at times ( )
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic