首页 > 技术文章 > 检查时异常和运行是异常 + 事务回滚 +隔离级别

prader6 2019-05-21 14:17 原文

  检查时异常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

推荐阅读