zoukankan      html  css  js  c++  java
  • 检查时异常和运行是异常 + 事务回滚 +隔离级别

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

  • 相关阅读:
    SpringBoot通过注解获取接口信息
    2.2.0Nginx代理与负载均衡
    1.1Nginx概述
    Nginx安装整合
    每日日报27
    PHP所遇问题——注意:未定义的索引
    每日日报26
    每日日报25
    每日日报24
    每日日报23
  • 原文地址:https://www.cnblogs.com/prader6/p/10899550.html
Copyright © 2011-2022 走看看