Transaction

Spring batch manage transaction at the chunk level. If there is a roll-back, it will roll-back the whole chunk. ^9971ac

Any exception happens at the Process or Write will be roll-back. However exception happens at Read level won't be roll back

Using with @Transactional

If we use @Transactional in spring batch by default with REQUIRED, it will merge the transaction with spring batch chunk level — hence doesn't do much.

Otherwise if we specify REQUIRES_NEW, it will start a new transaction but your application need to handle this transaction yourself. ^1a81c3

From listener

@Transactional only happens in the beforeChunk not afterChunk therefore if we use afterChunk we need to handle the transaction ourselves.