Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/sql/76.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
java事务不应回滚所有记录_Java_Sql_Database_Spring_Transactions - Fatal编程技术网

java事务不应回滚所有记录

java事务不应回滚所有记录,java,sql,database,spring,transactions,Java,Sql,Database,Spring,Transactions,在我的应用程序中,我将执行以下操作 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 an

在我的应用程序中,我将执行以下操作

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条记录将回滚,而不是所有记录都将回滚


有人能确认这是否是正确的方法吗?

确保在公共方法上设置了
@Transactional
注释。看

如果updateRecords()是私有方法,则注释将不起作用