What are the different propagation mechanisms in Spring transactions?

In Spring, there are several types of transaction propagation methods available.

  1. Option:
    REQUIRED (default): If a transaction currently exists, join that transaction; if no transaction currently exists, create a new transaction.
  2. If there is currently a transaction, it will be added to that transaction; if there is no current transaction, it will be executed in a non-transactional manner.
  3. MANDATORY: Join the current transaction if it exists; throw an exception if it does not.
  4. REQUIRES_NEW: A new transaction is created regardless of whether a transaction currently exists. If there is an existing transaction, it will be suspended.
  5. NOT_SUPPORTED: Perform the operation in a non-transactional manner. If there is currently a transaction, it will be suspended.
  6. NEVER: Perform actions in a non-transactional manner. Throw an exception if there is currently a transaction in progress.
  7. If there is an active transaction, the nested transaction will be executed within it. If there is no active transaction, a new one will be created. Nested transactions can be committed or rolled back independently without affecting the outer transaction’s commit or rollback.
bannerAds