@Transactional(propagation = Propagation.REQUIRED) tells Spring to join the transaction that is already running, or start a new one if none exists. It is the default propagation, so @Transactional alone behaves the same way. Every method that uses it shares one commit or rollback decision with its caller.
This makes REQUIRED the right choice for most service methods: a use case that calls several transactional services either succeeds as a whole or fails as a whole.
Spring's transaction interceptor checks for an active transaction when a REQUIRED method is called.
Because the participants share one physical transaction, they also share one database connection, one persistence context (with JPA), and one set of locks.
checkout starts the transaction. create and reserve join it. If reserve throws a RuntimeException, the order saved by create is rolled back as well.
By default Spring rolls back on unchecked exceptions (RuntimeException and Error). Checked exceptions commit the transaction unless you list them:
With REQUIRED there is a subtle trap. When an inner method that joined the transaction throws a rollback-triggering exception, Spring marks the shared transaction as rollback-only. If the outer method catches the exception and carries on, the final commit fails:
The outcome is an UnexpectedRollbackException at the end of process(). If the inner step is allowed to fail, run it with REQUIRES_NEW or NESTED instead.
| Propagation | Behaviour when a transaction exists | Behaviour when none exists |
|---|---|---|
REQUIRED | Join it | Start a new one |
REQUIRES_NEW | Suspend it, start a new one | Start a new one |
NESTED | Savepoint inside it | Start a new one |
SUPPORTS | Join it | Run without a transaction |
MANDATORY | Join it | Throw an exception |
NOT_SUPPORTED | Suspend it, run without | Run without a transaction |
NEVER | Throw an exception | Run without a transaction |
Spring Boot enables transaction management automatically when a transaction manager is present, so @EnableTransactionManagement is rarely needed.
this.create(cart) skips the proxy. Put the method in another bean.Yes. @Transactional without arguments is the same as @Transactional(propagation = Propagation.REQUIRED).
No. It joins the outer transaction, and the commit happens when the outermost method finishes.
An inner method that joined the transaction threw a rollback-triggering exception and the outer method swallowed it. The transaction is rollback-only, so the commit fails. Let the exception propagate or use a different propagation for the inner call.
No. The transaction is bound to the current thread, so work in another thread runs outside it.
Propagation.REQUIRED joins an existing transaction or starts a new one, which keeps related service calls atomic. It is the default, rolls back on unchecked exceptions, and shares one connection. Watch for self-invocation, swallowed exceptions that cause UnexpectedRollbackException, and use REQUIRES_NEW or NESTED only when part of the work must be independent.