Search code examples
kotlinspring-data-jpadata-class

Kotlin data class with spring jpa


I have read the spring guide with kotlin and its says data class for JPA is not recommended

but i am quite confused after seeing some tutorials and video using data class for JPA

did spring find a way to deal with data class in new versions?


Solution

  • We have developed several services with Spring and Kotlin and used data classes as e.g. entities. This works fine and leads to a lot less boilerplate. You do, however, need to configure your project with these build options/dependencies to avoid Spring interoperability issues:

    https://kotlinlang.org/docs/all-open-plugin.html