jpa-spring-data-kotlin-mapper
Skill18 starsChanged 9 months agoMITView on GitHub
Model Kotlin persistence code correctly for Spring Data JPA and Hibernate, including entity design, relationships, fetch plans, repository queries, lazy loading, and common performance traps. Use when creating or reviewing entities and repositories, diagnosing N+1 or `LazyInitializationException`, placing indexes and uniqueness rules, or preventing Kotlin-specific ORM bugs such as `data class` entities and broken `equals` or `hashCode`.
1 other project uses a version of this, 1 of them edited.
Adopted by
Most recently taken up by
- JetBrains/skillsedited, first seen Apr 28, 2026
Other versions1 project uses a version of this.
Word for word · 0
None found.
Edited · 1
- JetBrains/skills★ 36096% same
Wrote their own version · 0
None found.
How matches are found. Word for word: the exact same text. Edited: shares passages with this file (“99% same” means 99% of its five-word phrases also appear here; 10% or more counts). Their own version: similar meaning, or, weakest, the same name. We can’t tell which project had it first. Projects are counted among the 200 most-starred candidates, and mentions are links to the repository we found, up to 50 per site, so both counts are a floor.
In this repository24 other files it gives its agents.
- ci-cd-containerization-advisorSkill
- configuration-properties-profiles-kotlin-safeSkill
- dependency-conflict-resolverSkill
- domain-decomposition-api-design-advisorSkill
- error-model-validation-architectSkill
- gradle-kotlin-dsl-doctorSkill
- integration-resilience-engineerSkill
- jackson-kotlin-serialization-specialistSkill
- java-kotlin-migration-assistantSkill
- kotlin-idiomatic-refactorer-spring-awareSkill
- kotlin-spring-proxy-compatibilitySkill
- observability-integratorSkill
- performance-concurrency-advisorSkill
- production-incident-responderSkill
- project-context-ingestionSkill
- schema-migration-plannerSkill
- spring-context-di-reasoningSkill
- spring-kotlin-code-reviewSkill
- spring-mvc-webflux-api-builderSkill
- spring-security-configurator-auditorSkill
- stacktrace-log-triageSkill
- test-suite-builderSkill
- transaction-consistency-designerSkill
- upgrade-breaking-change-navigatorSkill
The file
Show its rules and text
We split this skill into the rules it gives an agent
22 rules. About 0 are common, 15 are distinctive, and 7 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈15
Distinctive · estimate
This author's own choices. Worth a look.
7
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Very specific: line 25
Do not generate JPA entities as data class.
- Distinctive: line 26
Keep transport DTOs and persistence entities separate unless the repository clearly uses a shared model on purpose.
- Distinctive: line 28
Treat lazy associations and optional associations carefully.
- Very specific: line 29
Use lateinit only when the project already accepts that tradeoff and the lifecycle is safe.
- Very specific: line 33
Never accept all-field equals and hashCode generated by a data class entity.
- Distinctive: line 34
Follow project conventions when they already define an entity identity strategy.
- Distinctive: line 35
If no convention exists, choose an identity approach that is stable under persistence and proxying, then explain the tradeoff.
- Distinctive: line 41
Prefer targeted fetch solutions:
- Distinctive: line 47
Use indexes and uniqueness constraints to support real query patterns and idempotency guarantees.
- Very specific: line 58
If open-in-view is disabled, DTO mapping that touches lazy fields must happen inside a deliberate transaction boundary.
- Distinctive: line 63
If a query is hot and read-only, DTO projection is often a better optimization than tuning entity graphs indefinitely.
- Distinctive: line 64
If a relationship exists only to simplify one query, question whether it belongs in the entity model or in a query model.
- Distinctive: line 65
Treat database indexes as part of the persistence design, not as a late production optimization.
- Very specific: line 69
Verify kotlin("plugin.jpa") or equivalent no-arg support when JPA entities exist.
- Distinctive: line 70
Verify classes and members are compatible with proxying where needed.
- Distinctive: line 71
Verify nullability reflects database truth rather than wishful API design.
- Distinctive: line 72
Verify repository return types and service expectations agree on null handling.
- Very specific: line 86
Do not recommend FetchType.EAGER everywhere to silence lazy loading symptoms.
- Distinctive: line 87
Do not expose entities directly through API responses by default.
- Very specific: line 88
Do not use data class entities.
- Distinctive: line 89
Do not claim an N+1 fix without explaining how the fetch plan changes query behavior.
- Distinctive: line 90
Do not place all persistence intelligence in repositories if the service layer controls the real access pattern.
≈ “Common” is an estimate: at least 1 in 5 of the 213,897 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
JPA Spring Data Kotlin Mapper
Source mapping: Tier 1 critical skill derived from Kotlin_Spring_Developer_Pipeline.md (SK-10).
Mission
Generate and review persistence mappings that are correct for both Hibernate semantics and Kotlin semantics. Prevent bugs that compile cleanly but fail under lazy loading, dirty checking, identity comparison, or query load.
Read First
- Entity classes and mapped superclasses.
- Repository interfaces and custom queries.
- Relevant service methods and transaction boundaries.
- SQL logs, execution plans, or symptoms such as N+1, deadlocks, or stale reads.
- Build files to verify JPA-related Kotlin compiler plugins.
Entity Design Rules
- Do not generate JPA entities as
data class. - Keep transport DTOs and persistence entities separate unless the repository clearly uses a shared model on purpose.
- Model required columns as non-null only when object construction and persistence lifecycle make that safe.
- Treat lazy associations and optional associations carefully. Nullable is often the honest model.
- Use
lateinitonly when the project already accepts that tradeoff and the lifecycle is safe.
Identity And Equality Rules
- Never accept all-field
equalsandhashCodegenerated by adata classentity. - Follow project conventions when they already define an entity identity strategy.
- If no convention exists, choose an identity approach that is stable under persistence and proxying, then explain the tradeoff.
- Be explicit about mutable fields and lazy associations when discussing equality semantics.
Query And Fetch Rules
- Diagnose N+1 by looking at actual query count or SQL logs, not by guessing from annotations alone.
- Prefer targeted fetch solutions:
@EntityGraphJOIN FETCH- batch fetching
- DTO projection
- Be careful with collection fetch joins plus pagination. Call out the tradeoff instead of hiding it.
- Use indexes and uniqueness constraints to support real query patterns and idempotency guarantees.
Advanced ORM Traps
- Maintain both sides of bidirectional associations in domain methods or helper functions. Half-updated object graphs are a common source of subtle bugs.
orphanRemovaland cascade remove are not interchangeable. Explain the lifecycle semantics before choosing one.toString, debug logging, JSON serialization, and IDE inspection can trigger lazy loads. Treat them as potential side effects, not harmless utilities.- Bulk update or delete queries bypass the persistence context and lifecycle callbacks. Call out when subsequent reads may be stale until clear or reload.
- Multiple bag fetches can explode under Hibernate. If a collection-heavy fetch plan looks "obviously convenient," verify whether the ORM can execute it safely.
Set-based collections plus mutable equality are especially dangerous. Collection membership can break after entity state changes.@Versionis usually the clearest optimistic concurrency mechanism when concurrent updates matter. Mention it explicitly when the use case can lose updates.- If
open-in-viewis disabled, DTO mapping that touches lazy fields must happen inside a deliberate transaction boundary.
Expert Heuristics
- Choose entity shape for write correctness first and read shape second. If reads need a different shape, use projections or dedicated queries.
- If a query is hot and read-only, DTO projection is often a better optimization than tuning entity graphs indefinitely.
- If a relationship exists only to simplify one query, question whether it belongs in the entity model or in a query model.
- Treat database indexes as part of the persistence design, not as a late production optimization.
Kotlin-Specific Checks
- Verify
kotlin("plugin.jpa")or equivalent no-arg support when JPA entities exist. - Verify classes and members are compatible with proxying where needed.
- Verify nullability reflects database truth rather than wishful API design.
- Verify repository return types and service expectations agree on null handling.
Output Contract
Return these sections:
Persistence model: the entity and relationship shape that should exist.Correctness risks: identity, lazy loading, transactional access, and nullability traps.Performance risks: N+1, fetch plan, query shape, pagination, and index concerns.Recommended changes: entity, repository, and query updates in minimal-diff form.Verification: tests or SQL-level checks that confirm the mapping works as intended.
Guardrails
- Do not recommend
FetchType.EAGEReverywhere to silence lazy loading symptoms. - Do not expose entities directly through API responses by default.
- Do not use
data classentities. - Do not claim an N+1 fix without explaining how the fetch plan changes query behavior.
- Do not place all persistence intelligence in repositories if the service layer controls the real access pattern.
Quality Bar
A good run of this skill improves correctness and query behavior together. A bad run proposes mappings that look neat in Kotlin but violate JPA identity, proxy, or loading semantics.
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

