9

I am using kotlin-jpa to generate default constructor to my kotlin entity, however, does are not being generated:

I just used:

id("org.jetbrains.kotlin.plugin.jpa") version "1.3.21"


@Entity
data class PlanSubscription(@Id ...

But event with the kotlin-jpa plugin the constructor is not generated:

No default (no-argument) constructor for class

5
  • 1
    You shouldn't use data classes for entities: the toString/hashCode/equals don't fit for entities, and entities should be open to support lazy-loading based on dynamic proxies. Commented Mar 18, 2019 at 19:47
  • What's the status of the question @Guilherme Torres Castro? Commented Mar 29, 2019 at 8:57
  • @Skizo-ozᴉʞS Sorry for the delay. I made a mistake and pasted the wrong plugin kotlin.jvm Instead of kotlin jpa. I edit the question to reflect that I'm already using the kotlin jpa plugin, but the no-arg constructors are not being generated. Commented Apr 5, 2019 at 18:12
  • You need to define an empty constructor, can you please add a default constructor for your class and try it again? Commented Apr 7, 2019 at 17:02
  • @Skizo-ozᴉʞS But that what the kotlin-jpa is supposed to do Commented Apr 8, 2019 at 16:07

2 Answers 2

0

I had a very similar issue. While the advice of not using data classes may or may not be a useful one I found that it was the version of the jpa plugin that was at issue try using version 1.3.41

id "org.jetbrains.kotlin.plugin.jpa" version "1.3.41"

Sign up to request clarification or add additional context in comments.

Comments

0

You need to set

`<dependency>
   <groupId>org.jetbrains.kotlin</groupId>
   <artifactId>kotlin-reflect</artifactId>
   <version>1.1.0</version>
</dependency>` 

in your pom.xml

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.