当前位置:网站首页>Seven propagation behaviors of transactions

Seven propagation behaviors of transactions

2022-07-07 13:59:00 Study notes of Aries orange

One 、 What is the communication behavior of affairs

The propagation behavior of a transaction refers to : When a transaction method is called by another transaction method , How should this transaction method work .
for example :methodA Method call methodB When the method is used ,methodB Is to continue to call A Running in the same transaction , Or start a new transaction for yourself . That's why methodB The business communication behavior determines .

Two 、 Seven communication behaviors of affairs

1、PROPAGATION_REQUIRED: If there is no current transaction , Just create a new transaction ; If there are currently transactions , Just join the change business ( This is the most common choice )
2、PROPAGATION_SUPPORTS: If there are currently transactions , Just join the transaction ; If there is no current transaction , It's non transactional
3、PROPAGATION_MANDATORY: If there are currently transactions , Just join the transaction ; If there is no current transaction , Throw an exception
4、PROPAGATION_REQUIRES_NEW: No matter whether there is a transaction or not , Both create new transactions
5、PROPAGATION_NOT_SUPPORTED: Perform operations in a non transactional way , If there are currently transactions , Suspend the current transaction
6、PROPAGATION_NEVER: To execute in a non transactional manner , If there are currently transactions , Throw an exception
7、PROPAGATION_NESTED:

3、 ... and 、 Understanding of the above concepts

1、 Transaction pending

for example Method A Support transactions , Method B Unsupported transaction , Method A Calling method B
In the method A Start running , The system establishes Transaction, Method A Database processing operations in , It's time to Transaction Under the control of . At this time , Method A Calling method B, Method A The open Transaction Will be suspended , Method B Any database operation in , Not at all Transaction Under the management of . When method B return , Method A Continue operation , Previous Transaction reply , The following database operations continue in this Transaction Under the control of Commit or rollback .

原网站

版权声明
本文为[Study notes of Aries orange]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/188/202207071040469396.html