博客
关于我
Spring事务的7种传播属性
阅读量:576 次
发布时间:2019-03-11

本文共 515 字,大约阅读时间需要 1 分钟。

Spring在TransactionDefinition接口中规定了7种事务传播行为,他们规定了事务方法和事务方法发生嵌套时事务如何进行传播。

所谓事务的传播行为是指,如果在开始当前事务之前,一个事务上下文已经存在,此时有若干选项可以指定一个事务性方法的执行行为。

  1. PROPAGATION_REQUIRED

    默认事务类型,如果没有,就新建一个事务;如果有,就加入当前事务。适合绝大多数情况。

  2. PROPAGATION_REQUIRES_NEW

    如果没有,就新建一个事务;如果有,就将当前事务挂起。

  3. PROPAGATION_NESTED

    如果没有,就新建一个事务;则创建一个事务作为当前事务的嵌套事务来运行。

  4. PROPAGATION_SUPPORTS

    如果没有,就以非事务方式执行;如果有,就使用当前事务。

  5. PROPAGATION_NOT_SUPPORTED

    如果没有,就以非事务方式执行;如果有,就将当前事务挂起。即无论如何不支持事务。

  6. PROPAGATION_NEVER

    如果没有,就以非事务方式执行;如果有,就抛出异常。

  7. PROPAGATION_MANDATORY

    如果没有,就抛出异常;如果有,就使用当前事务。即强制要有事务。

转载地址:http://emnvz.baihongyu.com/

你可能感兴趣的文章
nmon_x86_64_centos7工具如何使用
查看>>
NN&DL4.1 Deep L-layer neural network简介
查看>>
NN&DL4.3 Getting your matrix dimensions right
查看>>
NN&DL4.7 Parameters vs Hyperparameters
查看>>
NN&DL4.8 What does this have to do with the brain?
查看>>
nnU-Net 终极指南
查看>>
No 'Access-Control-Allow-Origin' header is present on the requested resource.
查看>>
No 'Access-Control-Allow-Origin' header is present on the requested resource.
查看>>
NO 157 去掉禅道访问地址中的zentao
查看>>
no available service ‘default‘ found, please make sure registry config corre seata
查看>>
No compiler is provided in this environment. Perhaps you are running on a JRE rather than a JDK?
查看>>
no connection could be made because the target machine actively refused it.问题解决
查看>>
No Datastore Session bound to thread, and configuration does not allow creation of non-transactional
查看>>
No fallbackFactory instance of type class com.ruoyi---SpringCloud Alibaba_若依微服务框架改造---工作笔记005
查看>>
No Feign Client for loadBalancing defined. Did you forget to include spring-cloud-starter-loadbalanc
查看>>
No mapping found for HTTP request with URI [/...] in DispatcherServlet with name ...的解决方法
查看>>
No mapping found for HTTP request with URI [/logout.do] in DispatcherServlet with name 'springmvc'
查看>>
No module named 'crispy_forms'等使用pycharm开发
查看>>
No module named 'pandads'
查看>>
No module named cv2
查看>>