Card 03/ 07
All 7 cards
ComparisonDifficulty: Advanced1 min
Choosing Between Them
Neither is the safe default. Each one fits a different shape of application, on the same two axes the previous two cards just demonstrated.
| Compared on | Spring Data JDBC | Spring Data JPA |
|---|---|---|
| Persistence context | None | Yes, with dirty checking |
| Lazy loading | None — loads in full | Yes, and it can fail outside a transaction |
| SQL behaviour | Predictable, close to what you wrote | Can be surprising — generated, sometimes deferred |
| Fits | Simple, mostly-flat domains; microservices; predictable CRUD | Complex relationships, rich domain models, an existing Hibernate investment |
A microservice with a flat domain and predictable SQL requirements is Spring Data JDBC's case — there's nothing complex enough for a persistence context to be worth its cost. A domain with genuine relationship depth, where a reader benefits from letting the framework manage loading and change-tracking rather than doing both by hand, is JPA's case. Neither one is "the safer default": each is safer for the domain it fits.