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); }
3、引用参考
--Spring事务的传播特性和隔离级别
http://www.iteye.com/topic/1147215