What are the different types of transaction propagation mechanisms in Spring?
In the Spring framework, there are several types of transaction propagation mechanisms.
- By default, add to the current transaction if one exists or create a new transaction if none exists.
- SUPPORTS: If there is currently a transaction, join it; if there is no transaction currently, run in a non-transactional manner.
- It is required to join the transaction if one currently exists, and to throw an exception if there is no transaction present.
- REQUIRES_NEW: Creates a new transaction, suspends the current transaction if it exists.
- NOT_SUPPORTED: Execute in a non-transactional manner, suspending the current transaction if one exists.
- NEVER: Perform in a non-transactional manner, throwing an exception if a transaction is currently in progress.
- If there is already a transaction in progress, the code will execute in a nested transaction; otherwise, a new nested transaction will be created.