has the following code:
public class Test{
@Autowired
private Dao dao;
@Autowired
private Service service;
@Transactional(propagation=Propagation.REQUIRED,rollbackForClassName="Exception")
//
public Object testA(List<Map<String, Object>> param) throws Exception {
return this.testA(param,this.dao);
}
@Transactional(propagation=Propagation.REQUIRED,rollbackForClassName="Exception")
public Object testA(List<Map<String, Object>> param,Dao targetDao) throws Exception {
...
...
//
service.testB(param2,targetDao);
}
@Transactional(propagation = Propagation.REQUIRED, rollbackForClassName = "Exception")
public void testB(Map<String, Object> param2,Dao targetDao) throws Exception {
...
//rollback-only
testC(param3,targetDao);
//
testD(param4,targetDao);
}
}
where the method testC is developed by other people and I call it. In this method, once an execution exception is encountered, the method is written to roll back. The statement is TransactionAspectSupport.currentTransactionStatus (). SetRollbackOnly ();.
when testing my entire method, I will throw an exception:
Caused by: org.springframework.transaction.UnexpectedRollbackException: Transaction rolled back because it has been marked as rollback-only
so I would like to ask my predecessors how to handle the error report on the basis of not adjusting the testC method, so that the program can encounter an exception and roll back normally?