This week's book giveaway is in the Agile and Other Processes forum.
We're giving away four copies of The Little Book of Impediments (e-book only) and have Tom Perry on-line!
See this thread for details.
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: Accessing more than one database in the same transaction

 
Hanna Habashy
Ranch Hand
Posts: 532
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi:

I need to access/insert/update to two databases at the same time using hibernate.

So far, I have one hibernate config. file for eatch database, however this approach requirs me to start different transaction for each database.

Is it possiple to access all databases in the same transaction?
Is it possiple to merge the hibernate config. files?

I am accessing MS SQL server 2005

thanks
[ December 07, 2007: Message edited by: Hanna Habashy ]
 
Edvins Reisons
Ranch Hand
Posts: 364
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Hanna Habashy:


Is it possiple to access all databases in the same transaction?


Yes, if you have JTA available; programmatically with UserTransaction, or container-managed.
 
Hanna Habashy
Ranch Hand
Posts: 532
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes, if you have JTA available; programmatically with UserTransaction, or container-managed.


I have JTA available, but how can I use it with Hibernate?
For each database, I create a hibernate configuration file (.cfg). So, there is a different session factory for each database, and hence I need a Transaction object for each database.

Thanks
 
Edvins Reisons
Ranch Hand
Posts: 364
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
With JTA, you can use your two Sessions/EntityManagers within the same (distributed) transaction.
[ December 11, 2007: Message edited by: Edvins Reisons ]
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic