检查时异常和运行是异常 + 事务回滚 +隔离级别

  检查时异常checked Exception 是编译检查时候就能发现的异常。这个能在try catch中处理,就在try catch 中处理。

  运行时异常(Runtime Exception),是程序遇到了问题,需要停下。这个不用try catch 处理,因为遇到这个程序就停下了。。。。。。 

  spring框架中能默认回滚的异常时 Runtime Exception.

  需要在方法上添加 
@Transactional(rollbackFor={Exception.class})

此文为笔记

参考链接:https://blog.csdn.net/qq_34406670/article/details/78945955

  https://blog.csdn.net/qq_18505715/article/details/76696439

 

@Transactional(propagation = Propagation.REQUIRED, rollbackFor = {Exception.class}, isolation = Isolation.DEFAULT, readOnly = false) 

 上面的 propagation = Propagation.REQUIRED是指的是事务的创建方式。

  isolation = Isolation.DEFAULT  是指的是数据库中事务的隔离级别 (只是暂时这样,理解)。

参考文章:https://blog.csdn.net/fight_man8866/article/details/81297929

转载于:https://www.cnblogs.com/prader6/p/10899550.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值