当前位置:网站首页>Transactional transaction propagation behavior?
Transactional transaction propagation behavior?
2022-07-26 12:42:00 【User 9919783】
Transaction propagation behaviors include 7 Kind of , Not interacting with the database , Database defined , It is spring The frame comes with .
This article mainly introduces three kinds of :required、nested、required_new.
Propagation_required( Communication requirements ): default , The most common , If there is no current transaction , Execute on the new transaction , If any , Join the current transaction execution . When the peripheral method does not open a transaction , Two internal transactions start this transaction without interfering with each other , And not affected by peripheral abnormalities .
Under the default propagation requirements , If an exception is caught in the inner transaction , Then other programs in this inner transaction run normally . Peripheral transactions caught exceptions , Peripheral and other internal transactions cannot run normally .
Propagation_supports( Communication support ): Support current transaction , If there is no business , It's non transactional .Propagation_mandatory( mandatory ): If there are currently no transactions , Throw an exception .
Propagation_requires_new: New transaction , If a transaction currently exists , Suspend the current transaction . When the peripheral method does not open a transaction , Two internal transactions start this transaction without interfering with each other , And not affected by peripheral abnormalities .
If the peripheral starts a transaction ,requeired Inner transactions and outer transactions are rolled back at the same time .
if requreis_new Inner transaction exception is not caught , be requeired The inner transaction and outer transaction are rolled back together , other requreis_new Internal affairs are not affected .
if requreis_new The inner transaction exception is trycatch Capture , Then other peripheral affairs will not be affected .
Propagation_not_supported( Not supported ): Operate with non transaction , If a transaction currently exists , Let the transaction hang .
Propagation_never: To execute in a non transactional manner , If a transaction currently exists , Throw an exception .
Propagation_nested( Propagate nesting ): If there are currently transactions , Then execute within the nest , If there is no transaction , execute Propagation_required operation . When the peripheral method does not open a transaction , Two internal transactions start this transaction without interfering with each other , And not affected by peripheral abnormalities .
1、propagaration_requeire_new And Propagation_nested The difference between nested propagation :
Nested If peripheral transactions are enabled , Because it is a parent-child nested transaction , Then the sub transactions are rolled back with the rollback of the peripheral main transaction , If the sub transaction rolls back, all transactions will be rolled back together , Unless the current sub transaction is trycatch Capture . and requeires_new Peripheral transactions and inner transactions are two transactions , Rollback of peripheral transactions does not affect internal transactions .
2、Nested and requeired difference :
Will roll back with the rollback of peripheral transactions .Requeired It belongs to joining peripheral affairs , Because they all belong to the same transaction , Once the inner transaction is rolled back, whether or not trycatch Capture , All rolled back together . and nested It belongs to sub transaction , There is a separate save node , therefore nested Method throws an exception trycatch Capture is rolled back , It will not affect peripheral affairs .
The code example is as follows :
required example , Use the default transaction instance , Whether or not exceptions are caught , Roll back all together
nested example , Because nested transactions , The outer and inner walls will roll back with each other , Unless the sub transaction is caught exception
required_new example , When the periphery throws an exception , It will not affect the normal storage of internal businesses in the database
边栏推荐
- 虚拟偶像代言产品出问题谁负责?且听律师分析
- The programmed navigation route jumps to the current route (the parameters remain unchanged), and if it is executed multiple times, it will throw a navigationduplicated warning error?
- 笔记。。。。
- The "2022 Huawei developer competition eastern China division opening ceremony" was successfully held in Fuzhou
- MySQL之数据查询(聚合函数)
- “2022华为开发者大赛中国区东部赛区开幕式”在福州成功举办
- Ds-24c/dc220v time relay
- [wechat applet] read the article, data request
- Hit the blackboard and draw the key points: a detailed explanation of seven common "distributed transactions"
- Minesweeping games - easy to play addictive (C language version)
猜你喜欢

华为超融合FusionCube解决方案笔记

How much do you know about the two infrastructures of the badminton stadium?

Notes....

自定义浏览器默认右击菜单栏

详解勒让德变换与共轭函数

LCD笔记(4)分析内核自带的LCD驱动程序

LCD notes (4) analyze the LCD driver of the kernel

Transformer dominates the world? Depth wise conv has something to say

Problems encountered in byte stream exercises and Solutions

Backtracking - question 51 Queen n -- a classic backtracking problem that must be overcome
随机推荐
MySQL之数据查询(聚合函数)
Vs code set the method of ctrl+s saving and automatic formatting
Backtracking - 46. Full arrangement
Some common writing methods and skills
14.2 byte stream learning
The programmed navigation route jumps to the current route (the parameters remain unchanged), and if it is executed multiple times, it will throw a navigationduplicated warning error?
食品安全 | 这些常见食物小心有毒!速查自家餐桌
Shell变量和引用
Sim900a based on STM32 sends short messages in Chinese and English
Analysis of Wireshark data package of network security B module of national vocational college skills competition Wireshark 0051.pcap
JDBC gets connections from the connection pool (Druid connection pool)
数据查询WHERE
Knowledge points of C language documents
Detailed explanation of Legendre transformation and conjugate function
【Map】万能的Map使用方法 & 模糊查询的两种方式
In the digital era, what "golden treasure" is driving the development of pharmaceutical enterprises for a century?
How to view encrypted information in text form
实体映射最强工具类:MapStruct真香
Minesweeping games - easy to play addictive (C language version)
酷早报:7月25日Web3加密行业新闻大汇总