Spring Data JPA 4.0
Last reviewed Sep 11, 2026
Prompt Details
Prompt Composition
4prompts
- Java 25113 lines · 2.8K tokens
- Hibernate ORM 7.274 lines · 2.3K tokens
- Spring Boot 4.083 lines · 3.7K tokens
- Spring Data JPA 4.079 lines · 3.4K tokens
Total349 lines · 12.3K tokens
CWE Coverage
- 15
- 20
- 22
- 59
- 78
- 79
- 88
- 89
- 95
- 117
- 190
- 201
- 208
- 209
- 214
- 250
- 295
- 297
- 306
- 319
- 323
- 327
- 338
- 346
- 347
- 352
- 362
- 367
- 378
- 379
- 409
- 427
- 444
- 470
- 471
- 494
- 502
- 532
- 611
- 613
- 614
- 639
- 653
- 681
- 732
- 749
- 770
- 772
- 776
- 789
- 807
- 862
- 863
- 915
- 916
- 918
- 922
- 942
- 943
- 1004
- 1275
- 1333
Prompt Preview
Apply the Hibernate ORM 7.2 and Spring Boot 4.0 baselines first. These rules cover Spring Data JPA 4.0.7 on the 2025.1 release train: repository exposure, generated and declared queries, value expressions, sorting and paging, specifications, projections, and bulk mutation.
Release alignment and repository exposure
- Build the
Sortfor a@NativeQueryor@Query(nativeQuery = true)method in code from an allowlisted client key, never from a request-suppliedSortorPageable, because nativeORDER BYtext isn't checked against the entity's properties. On 4.0.0 through 4.0.6, which predate the 4.0.7 fix, the sort-expression check also accepted characters outside the ASCII punctuation pattern, so a craftedSortvalue could reach that clause and be used to infer data on databases that accept non-ASCII SQL syntax. - Keep the stack the 4.0 train was built against together — Spring Framework 7.0, the matching Spring Data Commons 4.0 release, Hibernate ORM 7.2, Jakarta Persistence 3.2, and Java 17 or later — by letting the Spring Data release-train BOM and Boot's dependency management choose those versions, instead of overriding one of them on its own.
- Keep
JpaRepository,JpaSpecificationExecutor,QueryByExampleExecutor, andQuerydslPredicateExecutorbehind purpose-built service methods; a repository interface handed to a controller, GraphQL resolver, message listener, or agent tool is an unrestricted query surface. - Authorize the specific record and the specific state transition inside the transaction that loads it, because
findById,existsById,