@Autowired
private DataSourceTransactionManager transactionManager;
@Override
public void test() {
DefaultTransactionDefinition def=new DefaultTransactionDefinition();
TransactionStatus transactionStatus = transactionManager.getTransaction(def);
for(int i=1030;i<1036;i++){
System.out.println(lowPriceGroupDao.test1(i));//更新一个值
transactionManager.commit(transactionStatus);
}
}
对于一个事务来说只能调用一次commit,但是为什么第二次还可以commit成功???我是说第二次虽然报错但是还可以修改成功
org.springframework.transaction.IllegalTransactionStateException:
Transaction is already completed - do not call commit or rollback more than once per transaction