Card 07/ 07
Recap: Transactions
What @Transactional wraps, the rollback rule, self-invocation, and REQUIRES_NEW.
Transactions come down to the five ideas below, each listed with the card that covers it.
| The idea | Where |
|---|---|
@Transactional wraps one method, through a proxy, from entry to return or throw | @Transactional: What It Wraps and How |
| Every write in the method commits once, together | Transactions Example: Two Writes Committed Together |
Unchecked exceptions roll back; checked exceptions commit unless rollbackFor says otherwise | Rollback Rules: Checked Exceptions Commit by Default |
A call through this skips the proxy and runs with no transaction | Self-Invocation: Calling a @Transactional Method From the Same Class |
REQUIRES_NEW runs an independent transaction that survives the caller's rollback | Transaction Propagation: REQUIRES_NEW vs REQUIRED |
Most transaction bugs are one of two things: an exception type that does not roll back, or a call that never reached the proxy.
← → move through sections and cards