Add jdbc-vs-jpa module: Spring Data JDBC vs JPA on a shared Order aggregate

Same Customer/Order/OrderItem domain modelled with Hibernate/Spring Data JPA and
Spring Data JDBC side by side, both running through a shared StatementLoggingDataSource
so SQL-statement counts are directly comparable. 11 tests, 11 captured transcripts,
6 doc chapters. Companion repo for the ankurm.com article on when to drop the ORM.
This commit is contained in:
2026-09-17 19:09:35 +00:00
parent 585eed4d57
commit 448c383879
41 changed files with 1811 additions and 17 deletions
@@ -0,0 +1,9 @@
Scenario: two callers load the same order (both see version N), the first saves
(version becomes N+1), then the second — still holding version N — tries to save.
result: org.springframework.dao.OptimisticLockingFailureException: Failed to update versioned entity with id '1' (version '0') in table ["JDBC_ORDER"]; Was the entity updated or deleted concurrently?
@Version on the JDBC side behaves the same as @Version under JPA: the UPDATE's
WHERE clause includes "and version = :expectedVersion", zero rows match, and
Spring Data JDBC turns that into OptimisticLockingFailureException rather than
silently doing nothing.