Spring Data JPA 4.1

Last reviewed Sep 11, 2026

Export as PDF

Prompt Details

Prompt Composition

5prompts
  1. Java 25113 lines · 2.8K tokens
  2. Hibernate ORM 7.456 lines · 1.7K tokens
  3. Spring Framework 7.070 lines · 2.4K tokens
  4. Spring Boot 4.162 lines · 2.7K tokens
  5. Spring Data JPA 4.155 lines · 1.4K tokens
Total356 lines · 11K 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
  • 409
  • 427
  • 470
  • 471
  • 494
  • 502
  • 524
  • 532
  • 611
  • 639
  • 653
  • 681
  • 732
  • 749
  • 770
  • 772
  • 776
  • 789
  • 807
  • 829
  • 862
  • 863
  • 913
  • 915
  • 916
  • 918
  • 922
  • 942
  • 943
  • 1333

Prompt Preview

Apply the Hibernate ORM 7.4 and Spring Boot 4.1 baselines first. These rules cover Spring Data JPA 4.1.1 repositories, generated queries, projections, paging, and bulk mutations.

Repository and service boundaries

  • Expose purpose-specific service methods rather than a generic repository directly to controllers, GraphQL resolvers, data REST, message listeners, or tools.
  • Authorize the object and transition inside the service transaction; findById, existsById, and DomainClassConverter perform lookup, not ownership checks.
  • Derive tenant, owner, status, and security predicates from authenticated server context and include them in the repository query rather than filtering results afterward.
  • Do not call save with an attacker-populated entity graph; load the managed object, check its version and scope, then copy only permitted DTO fields.
  • Define transaction boundaries on service methods because declared query methods do not automatically inherit all CRUD transaction defaults.
  • Do not use @Transactional(readOnly=true) as a write-authorization check; it is an optimization hint and does not reliably reject modifying queries.

Query construction

  • Bind values in derived queries, @Query, @NativeQuery, specifications, and Query by Example; allowlist every dynamic property path, operator, projection, and native fragment.
  • Never pass request data to JpaSort.unsafe, which deliberately admits sort expressions that ordinary Sort rejects when they contain functions.
  • Allowlist ordinary Sort properties too, including nested paths, and lower