The propagation attribute of @Transactional tells Spring what to do when a transactional method is called while another transaction may already be active. It decides whether the method joins the existing transaction, suspends it and starts a new one, runs without a transaction, or fails. The default is Propagation.REQUIRED, which joins an existing transaction or creates one if none exists.
Choosing the right propagation level controls how commits and rollbacks spread across a chain of service calls, so it directly affects data consistency.
When service method A calls service method B and both are annotated with @Transactional, Spring has to decide whether B shares the transaction of A or gets its own. The propagation attribute answers that question per method:
Propagation only matters at the boundary between two transactional calls. Within a single method nothing changes, and it has no effect unless the call goes through the Spring proxy (see the self-invocation pitfall below).
| Level | Existing transaction present | No transaction present |
|---|---|---|
REQUIRED (default) | Joins it | Starts a new one |
REQUIRES_NEW | Suspends it, starts a new one | Starts a new one |
NESTED | Creates a savepoint inside it | Starts a new one |
SUPPORTS | Joins it | Runs without a transaction |
NOT_SUPPORTED | Suspends it, runs without one | Runs without a transaction |
MANDATORY | Joins it | Throws IllegalTransactionStateException |
NEVER | Throws IllegalTransactionStateException | Runs without a transaction |
Both methods share one physical transaction. If the inner method throws a runtime exception, Spring marks the whole transaction as rollback-only, and the outer method gets an UnexpectedRollbackException at commit time even if it caught the exception.
The outer transaction is suspended and the method runs in a completely independent transaction with its own connection. It commits or rolls back on its own. Use it for work that must persist regardless of the caller's outcome, such as audit logs.
If placeOrder later rolls back, the audit row is still committed. Remember that this holds two database connections at once, so heavy use can exhaust the connection pool.
NESTED runs inside the outer transaction but sets a JDBC savepoint. If the inner method fails, Spring rolls back to the savepoint and the outer transaction can continue. If the outer transaction rolls back, the nested work is rolled back too. It works with DataSourceTransactionManager over JDBC savepoints. JpaTransactionManager supports it only when the JDBC driver and the JPA dialect allow savepoints, and JTA transaction managers generally do not support it.
SUPPORTS suits read-only helpers that work with or without a transaction. Note that without one there is no real transaction synchronization.NOT_SUPPORTED suspends the current transaction, which is useful for calling a slow external system without holding a database transaction open.MANDATORY documents that a method must only be called from within a transaction and fails fast otherwise.NEVER fails if a transaction is active, which guards code that must not run transactionally.Spring rolls back on unchecked exceptions (RuntimeException and Error) by default. Checked exceptions commit unless you set rollbackFor.
| Scenario | Result |
|---|---|
Inner REQUIRED throws, outer catches it | Whole transaction is rollback-only; outer commit fails with UnexpectedRollbackException |
Inner REQUIRES_NEW throws, outer catches it | Only the inner transaction rolls back; outer can commit |
Inner NESTED throws, outer catches it | Rollback to the savepoint; outer can commit |
Outer throws after inner REQUIRES_NEW committed | Inner work stays committed; outer work rolls back |
Example of isolating a failure with REQUIRES_NEW:
One bad row rolls back only its own transaction, and the rest of the import proceeds.
@Transactional through a proxy, so a call from one method to another method of the same class bypasses the proxy and the propagation setting is ignored. Move the called method to another bean.REQUIRED chain, which causes the surprise UnexpectedRollbackException shown above.REQUIRES_NEW inside loops over many rows, which opens many connections and can deadlock when the outer transaction holds locks the inner one needs.NESTED works with every transaction manager. Check that your driver and manager support savepoints.REQUIRED. It matches the intuition that one business operation is one transaction.REQUIRES_NEW for audit trails, outbox writes you must keep, and per-item isolation in batch jobs.NESTED when a part of the work may fail and you want to retry or skip it without losing the rest, and your stack supports savepoints.MANDATORY and NEVER to enforce architectural rules.readOnly = true for query methods and set isolation and timeout separately; they are independent of propagation.The default is Propagation.REQUIRED: join the current transaction if one exists, otherwise create a new one.
REQUIRES_NEW uses a separate physical transaction that commits independently. NESTED stays inside the outer transaction and uses a savepoint, so it only commits when the outer transaction commits.
An inner method sharing the transaction threw a runtime exception, which marked the transaction rollback-only. Catching the exception in the outer method does not undo that mark.
No. The call bypasses the Spring proxy, so the annotation on the called method is not applied. Extract the method into a separate bean.
propagation defines how a @Transactional method relates to a transaction that is already running. REQUIRED shares it, REQUIRES_NEW isolates it, NESTED uses a savepoint, and the remaining levels enforce or avoid transactions. Know how rollback spreads between them and watch for proxy and connection-pool pitfalls.