The repository now aggregates two independent modules. migration-behavior/ is the
original project, moved unchanged; it stays on Spring Boot 4.0.6 / JDK 21 because
that is what the four published migration articles were verified against, and
upgrading it would silently invalidate output they quote. The article-tagged trees
are untouched, so links into a tag are unaffected.
transactions/ Companion code for "@Transactional in Spring: Propagation, Isolation,
and the Six Ways It Silently Does Nothing". Spring Boot 4.1.1 / JDK 25.
Every row of the propagation matrix is produced by calling the method and asking the
transaction manager what it did. The transaction NAME is the exhibit: a scope that
joined reports its caller's name, a scope that started its own reports its own.
Three things the transcripts settle:
- Propagation.NESTED cannot be used with JpaTransactionManager. It fails twice,
with two different messages, the second of which blames your JPA provider. The
savepoint manager comes from the object the JpaDialect returns when it begins the
transaction, and Hibernate's does not implement one. It works on
DataSourceTransactionManager, because a savepoint is a JDBC concept -- shown
working there rather than only failing here.
- Catching a REQUIRED inner failure does not save the transaction. The inner scope
has already marked it rollback-only, so the commit throws
UnexpectedRollbackException from a place with no connection to the cause.
- A checked exception commits, and so does a swallowed one. Those two do not merely
fail to start a transaction; they commit work the code was abandoning.
19 contract tests, six captured transcripts, all regenerated by scripts/run-all.sh.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Gip4srpzMwjgoba6uEfbr5
sdjpa4-demo
Companion code for the Spring Data JPA and transaction articles on ankurm.com.
Two independent Maven modules under one aggregator:
| Module | Article(s) | Boot / JDK |
|---|---|---|
migration-behavior/ |
the four Spring Data JPA 3→4 migration articles | 4.0.6 / 21 |
transactions/ |
@Transactional: propagation, isolation and the six silent failures | 4.1.1 / 25 |
The modules deliberately pin different Spring Boot versions. migration-behavior stays on
4.0.6 because that is what the four published migration articles were written and verified
against, and upgrading it would silently invalidate output those articles quote.
Moved in September 2026. The migration project used to live at the repository root. It is now under
migration-behavior/; source paths gained that prefix and nothing else changed. Thearticle-1-baseline,article-2-query-engineandarticle-3-advancedtags still point at the original layout, so a link into a tagged tree is unaffected.
./mvnw -DskipTests package # both modules
./mvnw test # every test in both
Tags
article-1-baseline,article-2-query-engine,article-3-advanced- the exact code each article quotes, frozen at publish time.corner-scenarios(andmain) - the enriched, current state described below. Some method signatures have moved on from the article-tagged snapshots (e.g.Book'spriceis now an embeddedMoneyvalue object, not a bareBigDecimal), so check out the matching article tag if you want the code to line up exactly with what's quoted in a given post.
What's covered beyond the three articles (corner-scenario enrichment)
- Refined Specification API (
AuthorSpecifications.java):PredicateSpecificationreused across a read and a bulk delete, an explicitDeleteSpecification(CriteriaDelete-backed), and anUpdateSpecification(CriteriaUpdate-backed bulk update composed from anUpdateOperation+ awhere(...)predicate). JpaSort.unsafe(...)with aCASEexpression - a realORDER BY case when country = 'US' then 0 else 1 endsort combined with a plain derived query.Money, an@Embeddablerecord value object onBook.price, with derived queries that traverse the embedded path (findByPriceAmountGreaterThanEqual,findByPriceAmount).- A genuine corner case, found by actually running it: a derived-query class-based (record) projection resolves constructor-parameter names against direct entity properties only.
BookSummary(String title, BigDecimal amount)does not resolveamountagainst the nestedprice.amountpath via a plainfindBy...derived method - it throwsPropertyReferenceException: No property 'amount' found for type 'Book'. The fix is an explicit@Queryconstructor expression (select new ...BookSummary(b.title, b.price.amount) from Book b where ...), which does work for nested/embedded paths. SeeBookRepository.findByPriceAmountLessThanEqual.
All of the above is exercised by both the demo runner (DemoRunner.java, sections H-L) and dedicated tests in MigrationBehaviorTests.java.