The Propagation enum in Spring controls what happens to a transaction when a @Transactional method is called while another transaction is already running (or not). It lets each method choose whether to join the caller's transaction, start its own, run without one, or fail. The default, REQUIRED, joins an existing transaction or creates a new one.
Spring defines seven propagation behaviours. Picking the wrong one is a common source of unexpected rollbacks, half-committed data and "why was my audit row lost" bugs, so it is worth knowing exactly what each does.
Transaction propagation answers one question: when method B is called from method A, does B share A's transaction? You set the answer with the propagation attribute of @Transactional:
Note that the enum you use in annotations is org.springframework.transaction.annotation.Propagation. The lower-level TransactionDefinition interface exposes the same behaviours as integer constants such as PROPAGATION_REQUIRED, which you use with TransactionTemplate or PlatformTransactionManager.
Propagation only matters when one transactional method calls another through a Spring proxy. Isolation level, timeout and read-only settings are separate attributes.
| Propagation | Existing transaction | No transaction |
|---|---|---|
REQUIRED (default) | Joins it | Starts a new one |
REQUIRES_NEW | Suspends it, starts a new one | Starts a new one |
NESTED | Runs in a savepoint inside it | Behaves like REQUIRED |
SUPPORTS | Joins it | Runs non-transactionally |
NOT_SUPPORTED | Suspends it, runs non-transactionally | Runs non-transactionally |
MANDATORY | Joins it | Throws IllegalTransactionStateException |
NEVER | Throws IllegalTransactionStateException | Runs non-transactionally |
Both methods share one physical transaction. If the inner method throws an exception that triggers rollback, the whole transaction is marked rollback-only. Even if the outer method catches the exception and carries on, the commit fails with UnexpectedRollbackException.
The current transaction is suspended and a new, independent one starts. It commits or rolls back on its own, regardless of what the outer transaction later does. This is the right tool for audit logs or outbox-style records that must survive an outer rollback.
Each REQUIRES_NEW call needs a second database connection while the first is suspended. Under load with a small connection pool, nesting these calls can exhaust the pool and deadlock the application.
A nested transaction runs inside the outer one using a JDBC savepoint. If the inner work fails, Spring rolls back to the savepoint and the outer transaction can continue and commit. If the outer transaction rolls back, the nested work is rolled back too. It works most reliably with DataSourceTransactionManager and JDBC, and it needs a database and driver that support savepoints. Support through JPA depends on the JpaDialect, so test it before relying on it.
SUPPORTS takes part in a transaction if one exists but does not require one. It suits read helpers that work either way.NOT_SUPPORTED suspends any transaction and runs without one, for example for a slow call to an external system that should not hold a connection.MANDATORY documents that a method must be called inside a transaction and fails fast otherwise.NEVER asserts that no transaction may be active.Both let an inner unit of work fail without necessarily aborting the outer one, but they differ in a way that matters for correctness.
REQUIRES_NEW | NESTED | |
|---|---|---|
| Physical transactions | Two | One, with a savepoint |
| Inner commit visible to others | Immediately after inner commit | Only when the outer commits |
| Outer rollback undoes inner work | No | Yes |
| Extra connection needed | Yes | No |
Use REQUIRES_NEW when the inner result must be durable no matter what happens outside. Use NESTED when the inner work is part of the same business operation but a partial failure can be retried or skipped.
@Transactional through a proxy, so calling this.record(...) from another method in the same class bypasses the proxy and the propagation setting is ignored. Move the method to another bean.RuntimeException and Error trigger rollback. Add rollbackFor = Exception.class when you need otherwise.REQUIRED, catching an inner exception does not undo the rollback-only mark.REQUIRED. The method joins the current transaction, or starts a new one when none exists.
No. The inner transaction commits independently once its method returns, so a later outer rollback does not undo it.
It can work, because the Hibernate dialect can use JDBC savepoints, but support varies by transaction manager and driver. Verify it with an integration test against your real database.
Most often because the call goes through this instead of the Spring proxy. Call the method on a different injected bean.
Propagation defines how a transactional method relates to the caller's transaction. Use REQUIRED for normal work, REQUIRES_NEW for independent, durable side effects, and NESTED for savepoint-based partial rollback. Reserve SUPPORTS, NOT_SUPPORTED, MANDATORY and NEVER for explicit constraints, and remember that propagation only takes effect when the call goes through the Spring proxy.