What are the transmission properties of Spring?

The propagation attribute of Spring is used to control the propagation behavior of transactions, including the following options:

  1. It is mandatory for the current method to run within a transaction. If a transaction is already in progress, the method will be added to it; if not, a new transaction will be created.
  2. SUPPORTS: Indicates that the current method supports running within a transaction, joining the transaction if one already exists; if no transaction exists, it will run non-transactionally.
  3. MANDATORY: Indicates that the current method must run within a transaction; if there is already a transaction, it will join that transaction, otherwise it will throw an exception.
  4. REQUIRES_NEW: Indicates that the current method must run in a new transaction, and if there is an existing transaction, it will be suspended.
  5. NOT_SUPPORTED: Indicates that the current method should not run within a transaction. If there is an existing transaction, it will be suspended.
  6. NEVER: This method should not be run within a transaction, and will throw an exception if a transaction is already in progress.
  7. NESTED: Indicates that the current method must run within a nested transaction. If a transaction already exists, the method will execute within the nested transaction. If no transaction exists, a new transaction will be created.

The transaction behavior of a method can be controlled by specifying propagation attributes in the @Transactional annotation.

bannerAds