• 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 ( )
 
my overalls have superpowers - they repel people who think fashion is important. Tiny ad:
the new thread boost feature brings a LOT of attention to your favorite threads
https://coderanch.com/t/674455/Thread-Boost-feature
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!