In my application, I am doing the following
1. Getting 25 records from the DB.
2. Update every 10 records
Here I have a loop to update every 10 records.so there will be 3 loops.
For each loop I need to have a new transaction.(so that only the 10 record will rollback and not all the records will rollback)
//line 1
getRecords();//25 records from DB //line 2
For(Records r: loop) { //line 3
add 10 records; //line 4
call update method(object with 10 records) //line 5
}
//line 6
updateRecords()//this method updates the 10 records\\line 7
Here I think I need to use @Transaction(REQUIRED) at line 6. so that only the 10 records will rollback and not all the records will rollback.
Can anyone please confirm if this is the correct approach?