1. Transaction propagation Type
New transaction
Required
Required_new-Suspend current
Non-transactional mode operation
Supports
not_supported-Suspend current
Never
Nested transactions:
Nested
Throw exception
Mandatory
Never
2. propagation_required
Joining a transaction that is currently being executed is not in another transaction, then a new transaction is started.
3.propagation_supports
If you are currently running in a transaction, that is, as a transaction, if it is no longer in a transaction, it will run as a non-transactional form.
4.propagation_mandatory
Must run in a transaction. In other words, he can only be called by a parent transaction. Otherwise, he will throw an exception.
5.propagation_requires_new
That's a bit of a detour. For example, we design Servicea.methoda with a transaction level of Propagation_required,serviceb.methodb of Propagation_requires_new, Then when the execution to the SERVICEB.METHODB, Servicea.methoda the transaction will be suspended, Serviceb.methodb will start a new transaction, waiting for the completion of the SERVICEB.METHODB transaction, he continues to execute. The difference between his affairs and Propagation_required is the degree of rollback of the transaction. because Serviceb.methodb is a new transaction, there are two different transactions. If the SERVICEB.METHODB has been committed, then Servicea.methoda fails to rollback, SERVICEB.METHODB is not rolled back. If Serviceb.methodb fails to roll back, if the exception he throws is captured by Servicea.methoda, the Servicea.methoda transaction may still be committed.
6.propagation_not_supported
Transactions are not currently supported. For example, Servicea.methoda's transaction level is propagation_required, and Serviceb.methodb's transaction level is propagation_not_supported, Then when execution to Serviceb.methodb, Servicea.methoda's transaction hangs, and he runs out of non-transactional state, and then continues the Servicea.methoda transaction.
7.propagation_never
Cannot run in a transaction. Suppose the transaction level of Servicea.methoda is propagation_required, and Serviceb.methodb's transaction level is Propagation_never, Then Serviceb.methodb will throw an exception.
8.propagation_nested
The key to understanding nested is savepoint. The difference between him and propagation_requires_new is thatpropagation_requires_new another transaction, which will be independent of his father's affairs, and that nested's affairs and his father's affairs are interdependent, His submission was to be submitted as a piece of his father's business. In other words, if the parent transaction is finally rolled back, he will also be rolled back .
The advantage of nested affairs is that he has a savepoint. That is, SERVICEB.METHODB failure rollback, then Servicea.methoda will also roll back to SavePoint point, Servicea.methoda can choose another branch, such as SERVICEC.METHODC, go ahead and try to do your own business. However, this transaction is not defined in the EJB standard.
Spring's transaction propagation mechanism