kotlin-backend-jpa-entity-mapping

安装量: 534
排名: #9231

安装

npx skills add https://github.com/kotlin/kotlin-agent-skills --skill 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. Show more

返回排行榜