---
name: "spring-data-jpa-repository-methods"
description: "Write complex database queries with derived method names, pagination, and JPA Specifications."
metadata:
  author: "Spring"
  version: "1.0.0"
  runtime_compatibility:
    - "codex"
    - "claude-code"
    - "cursor"
    - "windsurf"
triggers:
  - "spring data jpa derived query"
  - "jpa specification dynamic filter"
  - "spring data pageable"
permissions:
  fs_read: true
  fs_write: "workspace"
  shell_exec: false
  net_access: false
---

# Spring Data JPA Derived Query Methods & Specifications

Implements Spring Data JPA: JpaRepository interface, derived queries (findByStatusAndCreatedAtAfter), @Query with JPQL and native SQL, Pageable and Page responses, and dynamic predicate filtering using JpaSpecificationExecutor.

## When to Invoke
Invoke this skill whenever you need to:
- spring data jpa derived query
- jpa specification dynamic filter
- spring data pageable

## Execution SOP & Rules
1. Extend JpaRepository<User, Long> and JpaSpecificationExecutor<User> on repository interfaces.
2. Declare derived method: Page<User> findByActiveTrue(Pageable pageable);.
3. Write custom JPQL: @Query('SELECT u FROM User u JOIN FETCH u.orders WHERE u.id = :id') Optional<User> findWithOrders(Long id);.
4. Combine Specifications: Specification.where(hasName('Alex')).and(isOlderThan(20)).

## Verification Checklist
- Run local linting, syntax validation, and type-checks before reporting completion.
- Ensure all created or modified files adhere to workspace boundaries and avoid uncommitted secrets.
- Verify tests or build commands exit cleanly with return code 0.
