File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
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

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 is one way to manage transactions but I assume there would have to be major changes to include this. Or is it?

Sun Certified Java Programmer 1.5,
Sun Certified Web Component Developer 5.
"No pain. No Gain"
Suhas Bilaye
Ranch Hand

Joined: Sep 10, 2009
Posts: 80

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..


Thanks and Regards,
Royston Monteiro
Ranch Hand

Joined: Apr 25, 2008
Posts: 35

Thanks Suhas.

That solved the problem.
I agree. Here's the link:
subject: Managing Transactions for SQL Updates
It's not a secret anymore!