IntelliJ Java IDE
The moose likes Other Application Frameworks and the fly likes Spring transaction for two SessionFactories Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login
JavaRanch » Java Forums » Application Frameworks » Other Application Frameworks
Reply Bookmark "Spring transaction for two SessionFactories" Watch "Spring transaction for two SessionFactories" New topic
Author

Spring transaction for two SessionFactories

Aadil Pal
Greenhorn

Joined: Feb 23, 2006
Posts: 3
Hi,

I am new to spring and hibernate. I am trying to copy data from one database to another. I have two datasources defined in the applicationContext file . I need to have a transaction across the two hibernate session factories so that once I insert into database 2, I can go ahead and delete from database 1, is this possible declaratively in spring ?

I tried it based on the example on the spring website and it does not work.

Thanks
Aadil
Chris Mathews
Ranch Hand

Joined: Jul 18, 2001
Posts: 2712
Yes, Spring supports JTA transactions across multiple datasources. You will need to use org.springframework.transaction.jta.JtaTransactionManager, which of course means you will need to have a JTA implementation available. If you are running within a full J2EE Server this shouldn't be a problem... if not you could always integrate a standalone JTA implementation such as JOTM.

For more information I suggest reading through the Spring Transaction Management Documentation.
[ April 18, 2006: Message edited by: Chris Mathews ]
 
 
subject: Spring transaction for two SessionFactories
 
Threads others viewed
confusion?
Spring Hibernate Transaction 2
JTA Transaction
Hibernate & Spring performance problem
hibernate in Spring framework
MyEclipse, The Clear Choice