Official agent skill

Kotlin Backend Jpa Entity Mapping

by JetBrains in JetBrains/skills

Model Kotlin persistence code correctly for Spring Data JPA and Hibernate.

OfficialApache-2.0Auto-check passedMobile

Install Kotlin Backend Jpa Entity Mapping

skills CLI
$ npx skills add JetBrains/skills --skill kotlin-backend-jpa-entity-mapping -a claude-code

Project install by default; add -g for ~/.claude/skills/.

GitHub CLI
$ gh skill install JetBrains/skills kotlin-backend-jpa-entity-mapping --agent claude-code

Project scope by default; add --scope user for a personal install. Needs GitHub CLI 2.90.0 or later (public preview).

Manual copy
$ git clone --depth 1 https://github.com/JetBrains/skills.git skills-src && mkdir -p .claude/skills && cp -r skills-src/kotlin-backend-jpa-entity-mapping .claude/skills/kotlin-backend-jpa-entity-mapping && rm -rf skills-src

Use ~/.claude/skills/ instead of .claude/skills for a personal install. The folder must contain SKILL.md.

Claude Code skills documentation · loads skills from .claude/skills/

Facts

Skill name
kotlin-backend-jpa-entity-mapping
GitHub stars
366
Used in
2 other repos
Token cost
~1.8k tokens
SKILL.md length
525 words
Files
1
Skills in repo
76
Repo updated
First seen
Licence
Apache-2.0

At a glance

Model Kotlin persistence code correctly for Spring Data JPA and Hibernate.

  • Reviewing JPA (Java Persistence API) entities
  • SKILL.md covers Entity Design Rules, Identity and Equality, Uniqueness Constraints and Query and Fetch Rules, plus 2 more sections
  • Instructions only: no scripts, shell commands, URLs or credentials in SKILL.md
  • LazyInitializationException

What it does

Kotlin Backend Jpa Entity Mapping is an agent skill from JetBrains/skills, published by the product's own GitHub organization. Model Kotlin persistence code correctly for Spring Data JPA and Hibernate. Covers entity design, identity and equality, uniqueness constraints, relationships, fetch plans, and common ORM (Object-Relational Mapping) traps specific to Kotlin. Use when creating or reviewing JPA (Java Persistence API) entities, diagnosing N+1 or LazyInitializationException, placing indexes and uniqueness rules, or preventing Kotlin-specific bugs such as data class entities and broken equals/hashCode.

Its SKILL.md is about 1.8k tokens, which your agent loads only when the skill is triggered. It is a single SKILL.md file with no bundled scripts.

It sits in Mobile, covering Android development, ORMs and data access and Database schema design. It works with Kotlin and Java. The repository describes itself as: Curated agent skills collection verified by JetBrains. The licence is Apache-2.0.

When your agent uses it

  • Reviewing JPA (Java Persistence API) entities
  • LazyInitializationException
  • Placing indexes and uniqueness rules
  • Preventing Kotlin-specific bugs such as data class entities and broken equals/hashCode

Example prompts

  • “/kotlin-backend-jpa-entity-mapping”

What it can do on your machine

Read from SKILL.md and the folder at commit e0f258b. It shows what the files ask for, not the result of running them.

  • Tool permissions

    Pre-approves nothing: there is no allowed-tools line, so your agent's usual permission prompts apply.

    From allowed-tools in the SKILL.md frontmatter.

  • Runs code

    No scripts in the folder and no shell commands in SKILL.md (its code samples are kotlin).

    From the folder's file list and the shell code blocks in SKILL.md.

  • Network

    No URLs in SKILL.md.

    From URLs in SKILL.md, links to its own repository left out.

  • Credentials

    Names no API keys, tokens, secrets or passwords.

    From names ending in _API_KEY, _TOKEN, _SECRET, _KEY or _PASSWORD in SKILL.md.

Context cost

Kotlin Backend Jpa Entity Mapping loads about 1.8k tokens when it runs. Until then it costs about 131 tokens; SKILL.md has 525 words of instructions outside code blocks.

Always · name and description, kept in context so the agent knows when to use it
~131
When it runs · the whole SKILL.md, loaded when a task matches
~1.8k

Estimates: characters ÷ 4, the usual rule of thumb; real counts depend on the model's tokenizer. Scripts and assets cost tokens only if the agent reads them.

Safety

Auto-check passed

The automated check found no risky patterns in SKILL.md.

Automated static check — not a guarantee. Review scripts before installing. It scans the text of SKILL.md for risky patterns (piping downloads into a shell, reading credential files, hidden Unicode, destructive commands); files beside SKILL.md are not scanned.

SKILL.md

The full file from JetBrains/skills at commit e0f258b, republished under its Apache-2.0 licence (© JetBrains). 525 words, ~1,825 tokens.

Download SKILL.mdSave it as .claude/skills/kotlin-backend-jpa-entity-mapping/SKILL.md (or your agent's skills folder).
name
kotlin-backend-jpa-entity-mapping
description
Model Kotlin persistence code correctly for Spring Data JPA and Hibernate. Covers entity design, identity and equality, uniqueness constraints, relationships, fetch plans, and common ORM (Object-Relational Mapping) traps specific to Kotlin. Use when creating or reviewing JPA (Java Persistence API) entities, diagnosing N+1 or LazyInitializationException, placing indexes and uniqueness rules, or preventing Kotlin-specific bugs such as data class entities and broken equals/hashCode.
license
Apache-2.0
metadata.short-description
Model Kotlin JPA entities correctly
metadata.author
JetBrains
metadata.version
1.0.0
metadata.source
https://github.com/Kotlin/kotlin-agent-skills/tree/main/skills/kotlin-backend-jpa-entity-mapping

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

  • Never accept all-field equals/hashCode generated by data class on an entity.
  • Follow project conventions when they already define an identity strategy.
  • If no convention exists, use ID-based equality with a stable hashCode.
  • Be explicit about mutable fields and lazy associations when discussing equality.
Broken: data class Entity
kotlin
// WRONG: data class generates equals/hashCode from ALL fields
data class Order(
    @Id @GeneratedValue val id: Long = 0,
    var status: String,
    var total: BigDecimal
)
// BUG: order.status = "SHIPPED"; set.contains(order) → false (hash changed)
// BUG: Hibernate proxy.equals(entity) → false (proxy has lazy fields uninitialized)
Correct: Regular Class with ID-Based Identity
kotlin
@Entity
@Table(name = "orders")
class Order(
    @Column(nullable = false)
    var status: String,

    @Column(nullable = false)
    var total: BigDecimal
) {
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    val id: Long = 0

    override fun equals(other: Any?): Boolean {
        if (this === other) return true
        if (other !is Order) return false
        return id != 0L && id == other.id
    }

    override fun hashCode(): Int = javaClass.hashCode()

    // toString must NOT reference lazy collections
    override fun toString(): String = "Order(id=$id, status=$status)"
}

Key rules:

  • equals compares by ID only — stable under dirty tracking and proxy unwrapping
  • hashCode returns class-based constant — avoids Set/Map corruption after persist
  • toString excludes lazy-loaded relations — prevents LazyInitializationException
  • Constructor params are mutable entity fields; id is val with default

Uniqueness Constraints

When an API must be idempotent (e.g., "reserve stock for order X"), enforce uniqueness at both layers: database constraint for correctness, application check for clean errors.

Broken: No Duplicate Guard
kotlin
@Service
class ReservationService(private val repo: ReservationRepository) {
    @Transactional
    fun createReservation(variantId: Long, orderId: String, qty: Int): Reservation {
        // BUG: no check — duplicates silently accumulate
        return repo.save(Reservation(variantId = variantId, orderId = orderId, quantity = qty))
    }
}
Correct: Database Constraint + Application Guard
kotlin
@Entity
@Table(
    name = "reservations",
    uniqueConstraints = [
        UniqueConstraint(columnNames = ["variant_id", "order_id"])
    ]
)
class Reservation(
    @Column(name = "variant_id", nullable = false)
    val variantId: Long,

    @Column(name = "order_id", nullable = false)
    val orderId: String,

    @Column(nullable = false)
    var quantity: Int
) {
    @Id @GeneratedValue(strategy = GenerationType.IDENTITY)
    val id: Long = 0
}

interface ReservationRepository : JpaRepository<Reservation, Long> {
    fun findByVariantIdAndOrderId(variantId: Long, orderId: String): Reservation?
}

@Service
class ReservationService(private val repo: ReservationRepository) {
    @Transactional
    fun createReservation(variantId: Long, orderId: String, qty: Int): Reservation {
        repo.findByVariantIdAndOrderId(variantId, orderId)?.let {
            throw IllegalStateException(
                "Reservation already exists for variant=$variantId, order=$orderId"
            )
        }
        return repo.save(Reservation(variantId = variantId, orderId = orderId, quantity = qty))
    }
}

Key rules:

  • Database constraint is mandatory — application checks alone have race conditions
  • Application check provides clean error messages — without it, users get raw DataIntegrityViolationException
  • Both layers together: application catches the common case, database catches the race
  • Spring Data derives findByXAndY queries automatically
Show full SKILL.md (204 more words)Show less

Query and Fetch Rules

  • Diagnose N+1 by looking at actual query count or SQL logs, not by guessing from annotations.
  • Prefer targeted fetch solutions: @EntityGraph, JOIN FETCH, batch fetching, or DTO projection.
  • Be careful with collection fetch joins plus pagination — call out the tradeoff.
  • Use indexes and uniqueness constraints to support real query patterns.

Common ORM Traps

  • Bidirectional associations: maintain both sides in domain methods. Half-updated graphs cause subtle bugs.
  • orphanRemoval vs cascade remove: not interchangeable. Explain lifecycle semantics before choosing.
  • Lazy load triggers: toString, debug logging, JSON serialization, and IDE inspection can all trigger lazy loads.
  • Bulk updates/deletes: bypass persistence context and lifecycle callbacks. Subsequent reads may be stale.
  • Multiple bag fetches: can cause Cartesian explosion. Verify the ORM can execute collection-heavy fetch plans safely.
  • Set + mutable equality: collection membership can break after entity state changes.
  • @Version: the clearest optimistic concurrency mechanism when concurrent updates matter.
  • open-in-view disabled: DTO mapping touching lazy fields must happen inside a transaction boundary.

Guardrails

  • Do not use data class for JPA entities.
  • Do not recommend FetchType.EAGER everywhere to silence lazy loading symptoms.
  • Do not expose entities directly through API responses by default.
  • Do not claim an N+1 fix without explaining how the fetch plan changes query behavior.

© JetBrains, Apache-2.0. Rendered from Markdown: HTML in the file is shown as text, images as links, and headings moved down two levels. Raw file

Files

Just SKILL.md in kotlin-backend-jpa-entity-mapping of JetBrains/skills.

Open the folder on GitHubat commit e0f258b

Used in 2 other repositories

We found 2 copies of this SKILL.md (exact, near-identical or edited) in other folders, from 2 other GitHub owners. This page covers the copy in JetBrains/skills, which our catalogue first saw on October 7, 2026.

Compare with similar skills

Kotlin Backend Jpa Entity Mapping next to the 5 skills that share the most tags, products or categories with it. Stars are the repository's; “used in” counts other GitHub owners with a copy.

Kotlin Backend Jpa Entity Mapping compared with similar skills
SkillStarsUsed inTokensAuto-checkLicenceRepo updated
Kotlin Backend Jpa Entity Mapping this skillJetBrains/skills3662 repos~1.8kAutomated safety check: PassApache-2.0
Jimmer OrmCoooolfan/XiaomiAlbumSyncer421—~702Automated safety check: PassGPL-3.0
Harmonica DevKenjiOhtsuka/harmonica131—~742Automated safety check: PassMIT
Database Table Creatorc0x12c/ai-toolkit106—~1.1kAutomated safety check: PassNone
Build Teaql Appteaql/teaql-agent-kit2.8k—~4.6kAutomated safety check: PassMIT
Find Untested Sourcesmicrosoft/testfx1k2 repos~3.3kAutomated safety check: PassMIT

Similar skills

  • Jimmer Orm

    Coooolfan/XiaomiAlbumSyncer

    Jimmer ORM 开发助手(XiaomiAlbumSyncer 服务端),帮助编写实体映射代码、DTO 和 DSL 查询语句。适用于:(1) 定义或修改 Jimmer 实体(使用 @Entity 注解的 interface);(2) 编写 Jimmer DSL 查询代码;(3) 配置实体关联关系(@ManyToOne, @OneToMany, @ManyToMany);(4)…

    421 GitHub stars~702 tokensUpdated 5 days ago
    DatabasesAuto-check passed
  • Harmonica Dev

    KenjiOhtsuka/harmonica

    A skill your agent uses when working on the Harmonica Kotlin DB migration tool — planning, phase work, PRs, or anything touching this repo.

    131 GitHub stars~742 tokensUpdated 19 days ago
    MobileAuto-check passed
  • Database Table Creator

    c0x12c/ai-toolkit

    Creates database table with full Kotlin synchronization (SQL migration → Table → Entity → Repository → Tests).

    106 GitHub stars~1.1k tokensUpdated 3 mo ago
    MobileAuto-check passed
  • Build Teaql App

    teaql/teaql-agent-kit

    Build or change a TeaQL application in Java, Rust, Go, Swift, Python, C/.NET, or TypeScript, including Kotlin/JVM applications that consume Java-generated libraries.

    2.8k GitHub stars~4.6k tokensUpdated 14 days ago
    MobileAuto-check passed
  • Find Untested Sources

    microsoft/testfx

    Official

    MANDATORY for static source-to-test pairing: find or list source files/modules without corresponding tests, or suggest test locations from repository structure.

    1k GitHub starsUsed in 2 repos~3.3k tokens
    MobileAuto-check passed
  • Android Maps Ktx

    googlemaps/android-maps-ktx

    Provides idiomatic Kotlin extension (KTX) patterns, reactive Flow event streams, and multi-subscriber shareIn rules for Google Maps SDK for Android and its Utility Library.

    360 GitHub stars~897 tokensUpdated 3 days ago
    MobileAuto-check passed

More from JetBrains/skills

All 76 skills in this repo
  • Playwright

    JetBrains/skills

    Official

    A skill your agent uses when the task requires automating a real browser from the terminal (navigation, form filling, snapshots, screenshots, data extraction, UI-flow debugging) via playwright-cli…

    366 GitHub starsUsed in 11 repos~986 tokens
    Auto-check passed
  • Skill Creator

    JetBrains/skills

    Official

    Guide for creating effective skills. An agent skill from JetBrains/skills.

    366 GitHub starsUsed in 122 repos~4.7k tokens
    Auto-check passed
  • Transcribe

    JetBrains/skills

    Official

    Transcribe audio files to text with optional diarization and known-speaker hints.

    366 GitHub starsUsed in 4 repos~776 tokens
    Auto-check passed
  • Imagegen

    JetBrains/skills

    Official

    A skill your agent uses when the user asks to generate or edit images via the OpenAI Image API (for example: generate image, edit/inpaint/mask, background removal or replacement, transparent…

    366 GitHub starsUsed in 3 repos~2.5k tokens
    Auto-check passed
  • Speech

    JetBrains/skills

    Official

    A skill your agent uses when the user asks for text-to-speech narration or voiceover, accessibility reads, audio prompts, or batch speech generation via the OpenAI Audio API; run the bundled CLI…

    366 GitHub starsUsed in 3 repos~1.9k tokens
    Auto-check passed
  • Screenshot

    JetBrains/skills

    Official

    A skill your agent uses when the user explicitly asks for a desktop or system screenshot (full screen, specific app or window, or a pixel region), or when tool-specific capture capabilities are…

    366 GitHub starsUsed in 6 repos~2k tokens
    Auto-check passed

Works with

Categories

Questions about Kotlin Backend Jpa Entity Mapping

What does Kotlin Backend Jpa Entity Mapping do?

Model Kotlin persistence code correctly for Spring Data JPA and Hibernate. Kotlin Backend Jpa Entity Mapping is an agent skill from JetBrains/skills, published by the product's own GitHub organization. Model Kotlin persistence code correctly for Spring Data JPA and Hibernate.

When should I use Kotlin Backend Jpa Entity Mapping?

Kotlin Backend Jpa Entity Mapping fits situations like: reviewing JPA (Java Persistence API) entities; lazyInitializationException; placing indexes and uniqueness rules; preventing Kotlin-specific bugs such as data class entities and broken equals/hashCode.

How do I install Kotlin Backend Jpa Entity Mapping in Claude Code?

Run `npx skills add JetBrains/skills --skill kotlin-backend-jpa-entity-mapping -a claude-code`. Or copy the skill folder (kotlin-backend-jpa-entity-mapping in JetBrains/skills) into .claude/skills/kotlin-backend-jpa-entity-mapping in your project. Claude Code loads it when a task matches its description.

How do I install Kotlin Backend Jpa Entity Mapping in Codex?

Run `npx skills add JetBrains/skills --skill kotlin-backend-jpa-entity-mapping -a codex`. Or copy the skill folder (kotlin-backend-jpa-entity-mapping in JetBrains/skills) into .agents/skills/kotlin-backend-jpa-entity-mapping in your project. Codex loads it when a task matches its description.

Can I use Kotlin Backend Jpa Entity Mapping in Cursor, Gemini CLI or GitHub Copilot?

Cursor, Gemini CLI, GitHub Copilot and OpenCode also load SKILL.md folders. With the skills CLI, run `npx skills add JetBrains/skills --skill kotlin-backend-jpa-entity-mapping -a cursor` (or -a gemini-cli, github-copilot or opencode for the others). To copy it by hand, put the folder in .cursor/skills/kotlin-backend-jpa-entity-mapping, .gemini/skills/kotlin-backend-jpa-entity-mapping, .github/skills/kotlin-backend-jpa-entity-mapping and .opencode/skills/kotlin-backend-jpa-entity-mapping in your project.

What does Kotlin Backend Jpa Entity Mapping need to run?

SKILL.md names no scripts, command-line tools or credentials: Kotlin Backend Jpa Entity Mapping is instructions for the agent only.

Does Kotlin Backend Jpa Entity Mapping access the network?

SKILL.md contains no URLs. Any network use would come from the scripts or tools the agent runs. This is read from the text; nothing was executed.

Is Kotlin Backend Jpa Entity Mapping safe to install?

Our automated static check of SKILL.md found no risky patterns, such as piping downloads into a shell, reading credential files or hidden Unicode. It is not a guarantee. Review the folder before installing.

What licence does Kotlin Backend Jpa Entity Mapping use?

Kotlin Backend Jpa Entity Mapping is published under the Apache-2.0 licence (declared in SKILL.md). It allows redistribution, so the full SKILL.md is shown on this page.

How many tokens does Kotlin Backend Jpa Entity Mapping use?

About 1.8k tokens (SKILL.md is roughly 7.3k characters). Agents keep only the skill's name and description in context until a task matches; then they load SKILL.md in full.

What are the alternatives to Kotlin Backend Jpa Entity Mapping?

Skills that share tags, products or a category with Kotlin Backend Jpa Entity Mapping: Jimmer Orm (Coooolfan/XiaomiAlbumSyncer, 421 stars), Harmonica Dev (KenjiOhtsuka/harmonica, 131 stars), Database Table Creator (c0x12c/ai-toolkit, 106 stars) and Build Teaql App (teaql/teaql-agent-kit, 2.8k stars). The comparison table on this page puts their stars, adoption, token cost, safety result and licence side by side.

Who maintains Kotlin Backend Jpa Entity Mapping?

JetBrains (a GitHub organization, an official publisher) maintains it in JetBrains/skills, which has 366 GitHub stars. The repository holds 76 skills in this directory. The repository was last updated on June 29, 2026.

Source: JetBrains/skills on GitHub. Facts on this page come from the repository at the commit we read; the author's words are quoted as theirs.