Home » Java » Transmission mechanism in spring things

Transmission mechanism in spring things

Spring transaction propagation mechanism

Spring specifies 7 types of transaction propagation behavior in the TransactionDefinition interface, which specify how transactions and transaction methods occur when nested calls occur:

Transaction propagation behavior type

Explanation

PROPAGATION_REQUIRED

If there is no transaction at the moment, create a new transaction. If there is already a transaction, add it to this transaction. This is the most common choice,.


PROPAGATION_SUPPORTS

Supports the current transaction. If there is no transaction at the moment, execute in non transaction.


PROPAGATION_MANDATORY

Using the current transaction, throw an exception if there is no transaction at the moment.


PROPAGATION_REQUIRES_NEW

New transaction. If current transaction exists, suspend the current transaction.


PROPAGATION_NOT_SUPPORTED

Performs operations in non - transactional ways. If current transactions exist, suspend the current transaction.


PROPAGATION_NEVER

Non transactional execution. If an existing transaction exists, an exception is thrown.


PROPAGATION_NESTED

If there is a transaction currently, it is executed within nested transactions. If there is no transaction at the moment, the operation similar to that of PROPAGATION_REQUIRED is performed.

When using PROPAGATION_NESTED, the underlying data source must be based on JDBC 3, and the implementer needs to support the save point transaction mechanism.

Latest