프로그래밍/Java
try ~ catch 구문에서 트랜잭션 롤백 안되는 문제
choi_9182
2020. 10. 6. 12:15
@Transactional(rollbackFor=BusinessException.class)
public int insertTest(Map<String, Object> commandMap) throws BusinessException {
int cnt1;
int cnt2;
try {
cnt1 = sampleDao.insertTest1(commandMap);
cnt2 = sampleDao.insertTest2(commandMap);
} catch (Exception e) {
throw new BusinessException(".........");
}
return 0;
}
public int insertTest(Map<String, Object> commandMap) throws BusinessException {
int cnt1;
int cnt2;
try {
cnt1 = sampleDao.insertTest1(commandMap);
cnt2 = sampleDao.insertTest2(commandMap);
} catch (Exception e) {
TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
throw new BusinessException(".........");
}
return 0;
}
참조