Skip to content
kotlin avatar

Kotlin Backend Jpa Entity Mapping

Kotlin JPA entity guidance that replaces data classes with identity-safe classes, uniqueness constraints, and fetch plans.

CCM score
77 of 100
skills.sh installs
1.9K
GitHub stars
1.1K
last updated
Aug 21, 2026
View on GitHub

Own this skill? Claim it

What it does

  • Covers entity design, identity and equality, uniqueness constraints, relationships, fetch plans, and common Kotlin-specific ORM traps
  • Enforces regular classes instead of data class for entities, with ID-based equals, a stable hashCode, and toString that avoids lazy relations
  • Pairs database uniqueness constraints with application-level guards so duplicate reservations fail cleanly and races are still caught
  • Designed for Kotlin backend teams using Spring Data JPA and Hibernate when creating or reviewing entities, diagnosing N+1 issues, or placing indexes

Install

$ npx -y skills add kotlin/kotlin-agent-skills --skill kotlin-backend-jpa-entity-mapping -y

Installs into .agents/skills for every agent it finds here, and .claude/skills for Claude Code.

Files

JPA Entity Mapping for Kotlin

Kotlin's data class is natural for DTOs but dangerous for JPA entities. Hibernate relies on identity semantics that data class breaks: equals/hashCode over all fields corrupts Set/Map membership after state changes, and auto-generated copy() creates detached duplicates of managed entities.

This skill teaches correct entity design, identity strategies, and uniqueness constraints for Kotlin + Spring Data JPA projects.

Entity Design Rules

  • Never use data class for JPA entities. Use a regular class. Keep data class for DTOs.
  • Keep transport DTOs and persistence entities separate unless the project clearly uses a shared model.
  • Model required columns as non-null only when object construction and persistence lifecycle make it safe.
  • Use lateinit only when the project already accepts that tradeoff and the lifecycle is safe.
  • Verify kotlin("plugin.jpa") or equivalent no-arg support when JPA entities exist.
  • Verify classes and members are compatible with proxying where needed.

Identity and Equality

Details

Repository
github.com/kotlin/kotlin-agent-skills
Categories
Java & JVM, Databases
First seen
Jun 3, 2026

Questions

What does the kotlin-backend-jpa-entity-mapping skill do?

It guides an agent to model Kotlin persistence code correctly for Spring Data JPA and Hibernate, covering entity design, identity and equality, uniqueness constraints, relationships and fetch plans. It also helps prevent Kotlin-specific ORM bugs such as data class entities with broken equals and hashCode, and diagnoses N+1 queries and LazyInitializationException.

Where does this skill rank in its category?

It sits in the Java & JVM category on Claude Marketplaces and ranks in the top 50 there. Other skills in the category include java-springboot, springboot-patterns, java-coding-standards, jpa-patterns and kotlin-patterns.

How do I install the kotlin-backend-jpa-entity-mapping skill?

Run npx -y skills add kotlin/kotlin-agent-skills --skill kotlin-backend-jpa-entity-mapping -y in your project. Once installed, the agent follows its rules when creating or reviewing JPA entities.

Why shouldn't I use a data class for a JPA entity?

A data class generates equals and hashCode from all fields, which breaks Set and Map membership after an entity's state changes. Its copy function can also create detached duplicates of managed entities. This skill tells the agent to use a regular class with ID-based identity instead.

More from kotlin/kotlin-agent-skills

All 5

Similar to Kotlin Backend Jpa Entity Mapping

More Java & JVM