aspose file tools*
The moose likes Spring and the fly likes Managing Transactions for SQL Updates Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Spring
Bookmark "Managing Transactions for SQL Updates" Watch "Managing Transactions for SQL Updates" New topic
Author

Managing Transactions for SQL Updates

Royston Monteiro
Ranch Hand

Joined: Apr 25, 2008
Posts: 35

Hi Folks,
The DAO's I use currently, use JDBCTemplate for all SQL operations.
The application requires that a group of SQL updates should be done within a transaction, so that either all of them are committed together or all are rolled back.

I tried this with JDBCTemplate.batchUpdate, but it looks like each update within the batch is atomic, so a failure in one of them doesnt rollback the whole batch.

Please let me know if there is anyway to tweak JDBCTemplate so that we can control the atomicity of the batch.

I have found that org.springframework.transaction.support.TransactionTemplate is one way to manage transactions but I assume there would have to be major changes to include this. Or is it?




Cheers,
Roy.
Sun Certified Java Programmer 1.5,
Sun Certified Web Component Developer 5.
"No pain. No Gain"
http://cs.nyu.edu/~rpm319
Suhas Bilaye
Ranch Hand

Joined: Sep 10, 2009
Posts: 80
Hi,

Try doing transaction management using spring aop.. it might be easier..
I had faced the same problem i used the spring's transaction management api declaratively.. via aop..

Regards,
Suhas


Thanks and Regards,
Suhas
http://www.xplore-java.blogspot.com/
Royston Monteiro
Ranch Hand

Joined: Apr 25, 2008
Posts: 35

Thanks Suhas.

That solved the problem.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Managing Transactions for SQL Updates