0

I have a spring batch application which has a composite writer and both of the writers makes a call to stored procedure using simplejdbccall. The stored procedures takes the input and doing some data validations and iterations and inserts into a table. Both of the stored proc writes into same database but works on diff table.

The composite writer is used here because there are two different stored procedure needs to be called.

I see the first writer writes into DB through stored procedure even though the second writer fails. I dont see the first writer rolls back if the second one fails. Is it because its a stored proc? Can we still make the composite writer transactional ? Any change is required from stored procedure ? any idea? Thank you

user1570345
  • 193
  • 1
  • 1
  • 11
  • 1
    Without knowing what the SP does this will be impossible to answer. Why a composite writer, does it operate on the same db? Or something else? All in all far too little information to answer this question. – M. Deinum May 20 '22 at 14:31
  • @M.Deinum I have added some more information. – user1570345 May 20 '22 at 14:42
  • I see couple of commit statements present in the stored procudure – user1570345 May 20 '22 at 14:56
  • The transaction will be around the composite, no matter what type of delegates you register. This post might help: https://stackoverflow.com/questions/51904498/how-does-spring-batch-compositeitemwriter-manage-transaction-for-delegate-writer – Mahmoud Ben Hassine May 20 '22 at 15:27
  • If your SP is managing its own transaction, instead of participating in the current one, you cannot rollback. – M. Deinum May 20 '22 at 17:24
  • Thank you @M.Deinum. I removed the commits from the stored proc and tested it. The rollback worked fine at that time. It looks like the SP managing its own transaction. – user1570345 May 26 '22 at 14:10

0 Answers0