I am using spring batch to read data form database and write it to file.
Following are the steps involved:
1. Read data from database
2. Write data to file
3. Update database rows if file write is successful.
According to spring batch documentation and other sources, I can use JdbcBatchItemWriter for updating database entries. But I could not find any mechanism to control commit/rollback while updating the rows.
Say there are 100 rows and an error occurs at 45th row, I need to rollback all the updates.
Is there some way in JdbcBatchItemWriter to explicitly commit or rollback the transaction?
EDIT
The Itemwriter will data to file in chunks. Once a chunk is written, I need to update records in database. The database update is done using JdbcBatchItemWriter. Say 5 chunks are written successfully, and chunk 6 throws error in 45th record, I need to rollback all the chunks. Therefore I need commit/rollback control in JdbcBatchItemWriter.