본문으로 건너뛰기
cccskills
무료GitHub에 공개

spring-data-jpa

Use when designing or implementing Spring Data JPA on Spring Boot 4 — repository boundaries, projections, query patterns, custom repositories, CQRS read models, entity relationships, or persistence performance fixes. Not for generic SQL help, database admin work, or project-wide migration (see the springboot-migration skill).

한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.

설치 방법 보기

포함된 파일(12)

  • SKILL.md5.3 KB
  • assets/custom-repository.java15.1 KB
  • assets/dto-projection.java14.5 KB
  • assets/query-repository.java7.6 KB
  • assets/query-service.java14.7 KB
  • assets/relationship-patterns.java16.8 KB
  • references/cqrs-query-service.md6.4 KB
  • references/custom-repositories.md3.8 KB
  • references/dto-projections.md4.4 KB
  • references/performance-guide.md6.5 KB
  • references/query-patterns.md3.5 KB
  • references/relationships.md7.7 KB

SKILL.md(원문)

설치하기 전에 에이전트에게 전달되는 지시 내용을 확인할 수 있습니다.

Spring Data JPA Implementation

Purpose

Use this skill when the task is specifically about persistence design or implementation in a Spring Boot codebase. This skill adds value through aggregate-root guidance, query-pattern selection, CQRS read-model decisions, and the bundled repository and relationship templates.

Critical rules

  • Never create repositories for every entity. Create repositories only for aggregate roots.
  • Never rely on long derived query method names when the query has become non-trivial.
  • Never use save() blindly when entity state transitions matter; understand persist versus merge behavior.
  • Prefer projections or dedicated query services for read-heavy paths.
  • Keep transaction boundaries in the service layer unless the existing architecture intentionally does otherwise.

Workflow

Step 1: Identify the persistence problem

Collect the minimum context first:

  1. Is the type an aggregate root or an internal entity?
  2. Is the task primarily read-side, write-side, or both?
  3. Is the query simple lookup, filtered search, aggregation, projection, or dynamic criteria?
  4. Is the path performance-sensitive?
  5. Are there module-boundary or loose-coupling constraints that affect relationship modeling?

Step 2: Choose the implementation pattern

Use this table to decide what to load next.

PatternUse whenRead
Simple repositoryBasic CRUD and 1-2 simple lookupsExisting code or none
@Query repositoryMultiple filters, joins, sorting, readable JPQLreferences/query-patterns.md
DTO projectionRead-only and performance-critical responsesreferences/dto-projections.md
Custom repositoryCriteria API, bulk operations, EntityManager logicreferences/custom-repositories.md
CQRS query serviceSeparate read and write models, reporting, specialized read pathsreferences/cqrs-query-service.md

Use this decision guide:

NeedSimple@QueryDTOCustomCQRS
Basic CRUDYesYesNoYesYes
Custom filtersNoYesYesYesYes
Best read performanceNoSometimesYesSometimesYes
Complex dynamic logicNoNoNoYesYes
Clear read/write splitNoNoSometimesSometimesYes

Step 3: Load the matching reference

Load only the references needed for the current task:

  • references/query-patterns.md
  • references/dto-projections.md
  • references/custom-repositories.md
  • references/cqrs-query-service.md
  • references/relationships.md
  • references/performance-guide.md

Step 4: Apply the matching asset

Use the bundled templates in assets/ instead of rebuilding the pattern from scratch:

  • assets/query-repository.java
  • assets/dto-projection.java
  • assets/custom-repository.java
  • assets/query-service.java
  • assets/relationship-patterns.java

Templates use the same placeholder convention as creating-springboot-projects — {{PACKAGE}}, {{MODULE}}, {{NAME}}, {{TABLE_NAME}}, {{TYPE}}, {{FIELD}}. See creating-springboot-projects/SKILL.md#placeholder-convention for the full table.

Step 5: Validate relationships and transaction boundaries

Before finalizing the change, check:

  • repository exists only at the aggregate-root boundary
  • lazy-loading behavior is intentional
  • pagination or projections are used where row counts can grow
  • @ManyToMany has not been introduced when a join entity is more appropriate
  • read services use @Transactional(readOnly = true) where appropriate
  • write operations stay in service-layer transactions

Step 6: Validate performance-sensitive paths

Read references/performance-guide.md when the task includes:

  • N+1 risks
  • fetch-plan problems
  • unbounded queries
  • batch operations
  • heavy read views that should use projections

High-value patterns to prefer

Repository boundaries

  • Aggregate roots get repositories.
  • Internal child entities usually do not.

Query style

  • Use derived query methods for simple lookups.
  • Use @Query for joins, readable text blocks, or multiple filters.
  • Use DTO projections when the response does not need entities.
  • Use a CQRS query service when the read model differs from the write model.

Relationships

  • Prefer @ManyToOne over @OneToMany when possible.
  • Use IDs instead of entity references when loose coupling is more important than navigation.
  • Treat @ManyToMany as a warning sign; prefer an explicit join entity.

Output format

When proposing or implementing a persistence change, return:

## Recommended pattern
- Pattern:
- Why:

## Files to change
- `path/to/file`

## References used
- `references/...`

## Risks to verify
- ...

When not to use this skill

  • Generic SQL or database administration work outside Spring Data JPA
  • Whole-project migration planning
  • Broad project scaffolding that belongs in creating-springboot-projects

리뷰

아직 리뷰가 없습니다. 사용해 본 소감을 남겨 주세요.

댓글

로그인 없이 쓸 수 있습니다. 사용 후기, 질문, 작동하지 않은 환경 등을 편하게 남겨 주세요.

아직 댓글이 없습니다. 첫 댓글을 남겨 보세요.

보내면 바로 공개됩니다. 이메일 주소나 전화번호 같은 개인 정보는 쓰지 마세요. URL은 2개까지입니다.

0 / 1,000자

이 양식은 reCAPTCHA로 보호되며 Google 개인정보처리방침 및 서비스 약관이 적용됩니다.

같은 저장소의 스킬

Use when reviewing Spring Boot 4 / Java 17+ code with concrete files or diffs — pull requests, modules, or pasted Java/Spring sources — for migration risks, architecture boundary leaks, JSpecify null-safety gaps, security flaws, performance regressions, or Spring Data pitfalls. Not for Kotlin-only code, non-Spring frameworks, or generic review advice without code context.

한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.

a-pavithraa/springboot-skills-marketplace802026년 10월 23일 업데이트

Use when starting a new Spring Boot 4 project — scaffolding a service, REST API, or modular backend; picking an architecture (layered, package-by-module, modular-monolith, tomato, DDD-hexagonal); selecting Spring Boot 4 features; or applying the bundled templates and references in this skill. Not for migrating existing projects or for isolated JPA/repository work without broader project-creation context.

한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.

a-pavithraa/springboot-skills-marketplace802026년 10월 23일 업데이트

Use when upgrading an existing Spring Boot application to Boot 4 — dependency transitions, starter renames, test-annotation migration (e.g. @MockBean → @MockitoBean), Jackson 3 issues, related Spring Modulith 2 or Testcontainers 2 upgrade work, or planning a phased migration. Not for greenfield project creation or isolated repository design.

한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.

a-pavithraa/springboot-skills-marketplace802026년 10월 23일 업데이트

a-pavithraa의 스킬 모두 보기

이 스킬의 문제 신고