【发布时间】:2014-06-05 05:29:27
【问题描述】:
在我的应用程序中,我正在执行以下操作
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
我想我需要在第 6 行使用 @Transaction(REQUIRED)。 这样只有 10 条记录会回滚,而不是所有记录都会回滚。
谁能确认这是否是正确的方法?
【问题讨论】:
标签: java sql database spring transactions