Part 16 · Applications

Transactions, rollback and propagation boundaries

Prerequisites: 01-ecosystem

What does the transaction actually protect?

Transaction proxy: begin / participate; Database updates: quote + policy; Commit or rollback: configured rules; External email: outside DB atomicity. Connections: Transaction proxy to Database updates (invoke service); Database updates to Commit or rollback (method outcome); Database updates to External email (side effect risk)
One database transaction. Reactive transaction context, distributed coordination and propagation need separate treatment. [S30] [S31] [S19]

Goal & mental model verified

@Transactional defines an advised transaction boundary. Default rollback typically covers unchecked exceptions and Error; checked-exception behavior can be customized, including global defaults. Read-only is generally a hint, not a universal write prohibition.

[S30] [S31]

Worked example · design exercise synthesis

An issuePolicy service method updates the quote and inserts the policy in one database transaction. An email call is not rolled back just because the database transaction fails.

[S30] [S31] [S19]

Engineering decision synthesis

Keep boundaries around coherent database use cases and avoid long remote waits while holding connections. Choose explicit rollback policy and account for propagation and pool capacity.

[S30] [S31] [S19]

Pitfall & diagnosis synthesis

Self-invocation can bypass advice. Catching and swallowing a failure can prevent expected rollback. REQUIRES_NEW can require an additional connection and therefore worsen pool pressure.

[S30] [S31] [S19]

Improve & validate synthesis

Verify rollback through the proxied bean with real persistence. Exercise checked exceptions, concurrent conflicts and external side-effect failure separately.

[S30] [S31] [S19]
Keep this: A local transaction is a precise boundary, not a universal undo button.
Check yourself: Will a database rollback unsend an email?

No. External effects need separate coordination such as durable events and idempotent handling.

Sources & further reading

  1. [S19] Spring AOP proxies

    Spring project maintainers · documentation · accessed 2026-10-09 · Documentation retrieved 2026-10-09

    Supports: Proxy interception; Self-invocation bypass; Subclass limitations

    Read the linked section to validate the mechanism and its version-specific constraints.

  2. [S30] Declarative transactions

    Spring project maintainers · documentation · accessed 2026-10-09 · Documentation retrieved 2026-10-09

    Supports: Proxy entry required; Rollback defaults; Global rollback customization

    Read the linked section to validate the mechanism and its version-specific constraints.

  3. [S31] JPA transaction boundaries

    Spring project maintainers · documentation · accessed 2026-10-09 · Documentation retrieved 2026-10-09

    Supports: Service facade boundaries; Read-only is an optimization hint

    Read the linked section to validate the mechanism and its version-specific constraints.