Chunk Processing: failure and rollback
I have a simple batch program (reader/writer) with a chunk size of 5.
My input table has 20 numbers (1,2,3...,20)
I am copying these number to output table (chunk size of 5).
My writer is marked as @Transactional(propogation=Propogation.REQUIRES_NE W), so i expect that all the items in the chunk are inserted in same transaction)
When I come first time in my writer, i will have a list size of 5 => [1,2,3,4,5].
I insert the first 3 items, then on 4th item, before insert; i throw an exception deliberately. Since no exception is skipped; the job fails.
But, i notice that 3 items have been inserted to DB; i expected that the chunk of 5 will either all be inserted; or none will be inserted.
Is there any settings that have to be done to make all the items in a chunk insert in same transaction?