Working setup plus one small application per way of getting it wrong (no @Primary, @Primary only, url vs jdbc-url, wrong repository package, Flyway auto-configuration), plain vs named @Transactional, and ChainedTransactionManager with a failing commit. Transcripts are written by the tests. Co-Authored-By: Claude Sonnet 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Uu7q8vPeREyT4218EJPzz1
11 lines
534 B
Plaintext
11 lines
534 B
Plaintext
# A service method that writes to both databases, then throws
|
|
|
|
|
|
--- @Transactional (no name): Spring picks the @Primary manager, customersTransactionManager ---
|
|
thrown: java.lang.IllegalStateException: boom after both writes
|
|
rows after the rollback: customers.customer=0 orders.purchase_order=1
|
|
|
|
--- @Transactional("ordersTransactionManager"): the other database is now the one that rolls back ---
|
|
thrown: java.lang.IllegalStateException: boom after both writes
|
|
rows after the rollback: customers.customer=1 orders.purchase_order=0
|