当前位置:网站首页>事务的七种传播行为
事务的七种传播行为
2022-07-07 10:41:00 【白羊座橙子的学习笔记】
一、什么是事务的传播行为
事务的传播行为指的是: 当一个事务方法被另一个事务方法调用时,这个事务方法应该如何运行。
例如:methodA方法调用methodB方法时,methodB是继续在调用者A的事务中运行呢,还是为自己开启一个新事务运行。这就是由methodB的事务传播行为决定的。
二、事务的七种传播行为
1、PROPAGATION_REQUIRED:如果当前没有事务,就创建一个新事务;如果当前存在事务,就加入改事务(这是最常见的选择)
2、PROPAGATION_SUPPORTS:如果当前存在事务,就加入该事务;如果当前不存在事务,就以非事务执行
3、PROPAGATION_MANDATORY:如果当前存在事务,就加入该事务;如果当前不存在事务,就抛出异常
4、PROPAGATION_REQUIRES_NEW:无论当前存不存在事务,都创建新事务
5、PROPAGATION_NOT_SUPPORTED:以非事务方式执行操作,如果当前存在事务,就把当前事务挂起
6、PROPAGATION_NEVER:以非事务方式执行,如果当前存在事务,则抛出异常
7、PROPAGATION_NESTED:
三、上面一些概念的理解
1、事务挂起
例如 方法A支持事务,方法B不支持事务,方法A调用方法B
在方法A开始运行时,系统为它建立Transaction,方法A中对于数据库的处理操作,会在该Transaction的控制之下。这时,方法A调用方法B,方法A打开的 Transaction将挂起,方法B中任何数据库操作,都不在该Transaction的管理之下。当方法B返回,方法A继续运行,之前的Transaction回复,后面的数据库操作继续在该Transaction的控制之下 提交或回滚。
边栏推荐
- [statistical learning method] learning notes - support vector machine (Part 2)
- Leetcode skimming: binary tree 27 (delete nodes in the binary search tree)
- ip2long与long2IP 分析
- 聊聊Redis缓存4种集群方案、及优缺点对比
- visual stdio 2017关于opencv4.1的环境配置
- Day-19 IO stream
- BGP actual network configuration
- 2022a special equipment related management (boiler, pressure vessel and pressure pipeline) simulated examination question bank simulated examination platform operation
- Day-15 common APIs and exception mechanisms
- 在字符串中查找id值MySQL
猜你喜欢
Leetcode skimming: binary tree 22 (minimum absolute difference of binary search tree)
数据库安全的重要性
leetcode刷题:二叉树24(二叉树的最近公共祖先)
Master公式。(用于计算递归的时间复杂度。)
[爬虫]使用selenium时,躲避脚本检测
Several ways to clear floating
处理链中断后如何继续/子链出错removed from scheduling
leetcode刷题:二叉树22(二叉搜索树的最小绝对差)
Financial data acquisition (III) when a crawler encounters a web page that needs to scroll with the mouse wheel to refresh the data (nanny level tutorial)
2022 practice questions and mock examination of the third batch of Guangdong Provincial Safety Officer a certificate (main person in charge)
随机推荐
[difficult and miscellaneous]pip running suddenly appears modulenotfounderror: no module named 'pip‘
leetcode刷题:二叉树23(二叉搜索树中的众数)
leetcode刷题:二叉树26(二叉搜索树中的插入操作)
MPLS experiment
Multi row and multi column flex layout
@Resource和@Autowired的区别?
[deep learning] image multi label classification task, Baidu paddleclas
红杉中国完成新一期90亿美元基金募集
[疑难杂症]pip运行突然出现ModuleNotFoundError: No module named ‘pip‘
leetcode刷题:二叉树24(二叉树的最近公共祖先)
Day-15 common APIs and exception mechanisms
[pytorch practice] write poetry with RNN
[binary tree] delete points to form a forest
货物摆放问题
Leetcode skimming: binary tree 27 (delete nodes in the binary search tree)
《ASP.NET Core 6框架揭秘》样章[200页/5章]
[pytorch practice] use pytorch to realize image style migration based on neural network
How to apply @transactional transaction annotation to perfection?
[statistical learning methods] learning notes - Chapter 4: naive Bayesian method
[Q&A]AttributeError: module ‘signal‘ has no attribute ‘SIGALRM‘