my dog learned polymorphism*
The moose likes Spring and the fly likes Using Single transaction accross  multiple datasources Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Spring
Bookmark "Using Single transaction accross  multiple datasources" Watch "Using Single transaction accross  multiple datasources" New topic
Author

Using Single transaction accross multiple datasources

yogessh chavaan
Greenhorn

Joined: Apr 08, 2011
Posts: 13

Hello ,

I have to use spring and hibernate to delete two records from two different datasources , but this should be done in single transaction i.e if deletion of one record fails , the other should not be executed or should be rolledback.
Could any one please guide me how this can be achieved?

Thanks in advance
Yogesh Chavan
Mark Spritzler
ranger
Sheriff

Joined: Feb 05, 2001
Posts: 17260
    
    6

Standard DataSources and Transaction Managers cannot do this.

You have to use DataSources and Transaction Manager that supports two phase commits. XA Transactions. Such a transaction manager would be a JTA Transaction Manager in an App Server, or a third party tx manager. And the DataSource resource has to be XA compliant.

Mark


Perfect World Programming, LLC - Two Laptop Bag - Tube Organizer
How to Ask Questions the Smart Way FAQ
yogessh chavaan
Greenhorn

Joined: Apr 08, 2011
Posts: 13

Thanks Mark ,
I will look into XA transactions and JTA. if you have , can you please provide any links for references..with spring hibernate and JTA.

Yogesh
Mark Spritzler
ranger
Sheriff

Joined: Feb 05, 2001
Posts: 17260
    
    6

yogessh chavaan wrote:Thanks Mark ,
I will look into XA transactions and JTA. if you have , can you please provide any links for references..with spring hibernate and JTA.

Yogesh


There is nothing different between non JTA and JTA when it comes to Spring with Transactions. I recommend taking the "Core Spring" class, or reading SpringSource's documentation.

Mark
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Using Single transaction accross multiple datasources