<!-- mobian-agent-page publisher="dailydev" canonical="https://daily.dev/posts/how-to-avoid-common-pitfalls-with-jpa-and-kotlin-hgchpvpwb" -->

---
title: How to Avoid Common Pitfalls With JPA and Kotlin | daily.dev
description: Jakarta Persistence (JPA) was designed for Java, creating friction with Kotlin's defaults like final classes, immutable properties, and null safety. To build...
canonical: https://daily.dev/posts/how-to-avoid-common-pitfalls-with-jpa-and-kotlin-hgchpvpwb
twitter:card: summary_large_image
twitter:site: @dailydotdev
og:type: website
og:site_name: daily.dev
og:title: How to Avoid Common Pitfalls With JPA and Kotlin | daily.dev
og:description: Jakarta Persistence (JPA) was designed for Java, creating friction with Kotlin's defaults like final classes, immutable properties, and null safety. To build...
og:url: https://daily.dev/posts/how-to-avoid-common-pitfalls-with-jpa-and-kotlin-hgchpvpwb
og:image: https://api.daily.dev/og/posts/HgcHpVPwb.png
og:image:alt: How to Avoid Common Pitfalls With JPA and Kotlin
og:image:width: 1200
og:image:height: 630
og:locale: en
---

> ## Documentation Index
> Fetch the complete documentation index at: https://daily.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# How to Avoid Common Pitfalls With JPA and Kotlin

**[Kotlin](https://daily.dev/sources/kotlin)** · 15 min read · 1 upvotes · 0 comments

## Summary

Jakarta Persistence (JPA) was designed for Java, creating friction with Kotlin's defaults like final classes, immutable properties, and null safety. To build reliable persistence layers, avoid data classes for entities, use regular open classes with mutable properties, configure the no-arg and all-open compiler plugins, stick to field-based access, and make all entity fields nullable (including primary keys with generated values). Default values in constructors won't apply when loading from the database. Kotlin 2.2 improves annotation placement, and IntelliJ IDEA 2026.1 will detect these issues automatically with inspections and quick-fixes.

## Full article

daily.dev links to this article rather than hosting it. Read it at the original source: <https://blog.jetbrains.com/idea/2026/01/how-to-avoid-common-pitfalls-with-jpa-and-kotlin/>

## Similar posts on daily.dev

- [Using Spring Data JDBC With Kotlin](https://daily.dev/posts/using-spring-data-jdbc-with-kotlin-jtkj8jwli) · JetBrains · 0 upvotes · 0 comments
- [Null-Safe applications with Spring Boot 4](https://daily.dev/posts/null-safe-applications-with-spring-boot-4-ufnxqhfid) · Spring · 132 upvotes · 0 comments
- [Stop Using Java When Kotlin Exists](https://daily.dev/posts/stop-using-java-when-kotlin-exists-ib2r2pgex) · Atomic Spin · 35 upvotes · 8 comments
- [Jakarta Data Makes Persistence a Breeze](https://daily.dev/posts/jakarta-data-makes-persistence-a-breeze-rsbio0c0q) · Foojay.io · 0 upvotes · 0 comments

---

Tags: [#devtools](https://daily.dev/tags/devtools), [#java](https://daily.dev/tags/java), [#kotlin](https://daily.dev/tags/kotlin), [#spring](https://daily.dev/tags/spring)

[View this post on daily.dev](https://daily.dev/posts/how-to-avoid-common-pitfalls-with-jpa-and-kotlin-hgchpvpwb)

```json
{"@context":"https://schema.org","@graph":[{"@type":"Organization","@id":"https://daily.dev/#organization","name":"daily.dev","url":"https://daily.dev","logo":{"@type":"ImageObject","url":"https://daily.dev/apple-touch-icon.png","width":180,"height":180},"sameAs":["https://twitter.com/dailydotdev","https://github.com/dailydotdev","https://www.linkedin.com/company/daily-dev-ltd"]},{"@type":"WebSite","@id":"https://daily.dev/#website","url":"https://daily.dev","name":"daily.dev","publisher":{"@id":"https://daily.dev/#organization"},"potentialAction":{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https://daily.dev/search?q={search_term_string}"},"query-input":"required name=search_term_string"}}]}
{"@context":"https://schema.org","@type":"TechArticle","headline":"How to Avoid Common Pitfalls With JPA and Kotlin","url":"https://daily.dev/posts/how-to-avoid-common-pitfalls-with-jpa-and-kotlin-hgchpvpwb","mainEntityOfPage":{"@type":"WebPage","@id":"https://daily.dev/posts/how-to-avoid-common-pitfalls-with-jpa-and-kotlin-hgchpvpwb"},"datePublished":"2026-01-20T18:49:15.012Z","dateModified":"2026-03-15T03:29:22.014Z","description":"Jakarta Persistence (JPA) was designed for Java, creating friction with Kotlin's defaults like final classes, immutable properties, and null safety. To build...","image":"https://media.daily.dev/image/upload/f_auto,q_auto/v1/posts/c21380cb433a13ec73dced0923159eb3?_a=AQAEulh","thumbnailUrl":"https://media.daily.dev/image/upload/f_auto,q_auto/v1/posts/c21380cb433a13ec73dced0923159eb3?_a=AQAEulh","isAccessibleForFree":true,"articleSection":"Kotlin","inLanguage":"en","publisher":{"@type":"Organization","name":"daily.dev","url":"https://daily.dev","logo":{"@type":"ImageObject","url":"https://daily.dev/apple-touch-icon.png","width":180,"height":180}},"author":{"@type":"Organization","name":"Kotlin","logo":"https://media.daily.dev/image/upload/t_logo,f_auto/v1/logos/kotlin","url":"https://daily.dev/sources/kotlin"},"commentCount":0,"discussionUrl":"https://daily.dev/posts/how-to-avoid-common-pitfalls-with-jpa-and-kotlin-hgchpvpwb","interactionStatistic":[{"@type":"InteractionCounter","interactionType":{"@type":"LikeAction"},"userInteractionCount":1},{"@type":"InteractionCounter","interactionType":{"@type":"CommentAction"},"userInteractionCount":0}],"keywords":"devtools,java,kotlin,spring","timeRequired":"PT15M"}
{"@context":"https://schema.org","@type":"BreadcrumbList","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https://daily.dev"},{"@type":"ListItem","position":2,"name":"Kotlin","item":"https://daily.dev/sources/kotlin"},{"@type":"ListItem","position":3,"name":"How to Avoid Common Pitfalls With JPA and Kotlin"}]}
```

