jpa-spring-data-kotlin-mapper

Diagnose Kotlin persistence mappings for Spring Data JPA and Hibernate.

14|1|Updated Mar 6, 2026
One-click install
npx skills add https://github.com/kbrgnj/kotlin-backend-agent-skills --skill jpa-spring-data-kotlin-mapper-kbrgnj
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: jpa-spring-data-kotlin-mapper
Source: https://github.com/kbrgnj/kotlin-backend-agent-skills/tree/main/.agents/skills/jpa-spring-data-kotlin-mapper
Command: npx skills add https://github.com/kbrgnj/kotlin-backend-agent-skills --skill jpa-spring-data-kotlin-mapper-kbrgnj

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

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.

Core Features & Use Cases

  • Entity design and mapping guidance for Kotlin with JPA and Hibernate to ensure correct proxying, identity, and lifecycle semantics.
  • Query optimization and fetch strategies to avoid N+1, including EntityGraph, JOIN FETCH, batch fetching, and projections.
  • Kotlin-specific considerations and guardrails to prevent common pitfalls like data class entities and incorrect equals/hashCode, with guidelines for indexing and transactional boundaries.

Quick Start

Review your Kotlin entity models and repository interfaces, then apply the guidelines to fix lazy loading and identity issues.

Frequently Asked Questions about jpa-spring-data-kotlin-mapper

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
Why does Hibernate throw a LazyInitializationException with Kotlin JPA entities?

LazyInitializationException in Kotlin JPA entities occurs when accessing uninitialized proxies outside a transactional boundary. Proper fetch plans, EntityGraph usage, or JOIN FETCH directives ensure associations are loaded within the persistence context.

Can I use Kotlin data classes as JPA entities in Spring Data?

Using Kotlin data classes as JPA entities is discouraged because Hibernate proxying and lifecycle semantics break their equals/hashCode contracts. Regular classes with proper identity handling ensure correct proxying and maintainable persistence behavior.

How do I fix N+1 query issues in Spring Data JPA repositories?

Fix N+1 query issues in Spring Data JPA by applying fetch strategies like EntityGraph, JOIN FETCH, batch fetching, or projections. Optimizing fetch plans across entities and repositories prevents excessive database hits during relationship loading.

What is the best way to implement equals and hashCode for Kotlin JPA entities?

Implementing equals and hashCode for Kotlin JPA entities requires careful identity handling to avoid proxy issues. Use stable business keys or identifier-based comparisons rather than data class auto-generated methods for safe persistence behavior.

How do I configure indexing and uniqueness rules in Hibernate entity design?

Configure indexing and uniqueness rules in Hibernate entity design by applying appropriate mapping annotations. Proper indexing strategies and uniqueness constraints across entities optimize query performance and enforce data integrity.

Does Spring Data JPA support Kotlin nullability for optional entity relationships?

Spring Data JPA supports Kotlin nullability for optional entity relationships, but requires careful proxying and nullability handling. Proper mapping ensures that lazy-loaded associations respect Kotlin's null safety without breaking Hibernate's initialization logic.