1、Spring项目中事务手动回滚:
或者抛出异常:
}
引用:
http://blog.csdn.net/yh88356656/article/details/52174817
2、
TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
或者抛出异常:
@Transactional(rollbackFor = { Exception.class, RuntimeException.class })
public HousingFundDto slogin(){
try {
...
throw new BusinessException("无法查询基本信息");
...}catch (BusinessException e) {
throw new BusinessException(e.getErrorDesc());
}
}
引用:
http://blog.csdn.net/yh88356656/article/details/52174817
2、
/**
* 更新
*/
@Transactional(rollbackFor = { Exception.class, RuntimeException.class })
public void update(Entity entity) {
targetDao.update(entity);
}
/**
* 新增
*/
@Transactional(rollbackFor = { Exception.class, RuntimeException.class })
public void insert(Entity entity) {
targetDao.insert(entity);
}