Card 07/ 07

RecapDifficulty: Advanced1 min

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.

What the topic established, and which card it was on
The ideaWhere
@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, togetherTransactions Example: Two Writes Committed Together
Unchecked exceptions roll back; checked exceptions commit unless rollbackFor says otherwiseRollback Rules: Checked Exceptions Commit by Default
A call through this skips the proxy and runs with no transactionSelf-Invocation: Calling a @Transactional Method From the Same Class
REQUIRES_NEW runs an independent transaction that survives the caller's rollbackTransaction 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.