Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Koitlin support for JPA static metamodel

When I create an Entity class using Java JPA static meta models are generated.

If I convert my Entities to Kotlin JPA static metamodels are not generated.

How to solve this problem?

EDIT

I am using Gradle as build tool.

like image 816
A0__oN Avatar asked Dec 20 '17 10:12

A0__oN


2 Answers

I had to use kapt plugin.

I had to add following line to my build.gradle file.

kapt "org.hibernate:hibernate-jpamodelgen:${hibernate_version}"
like image 65
A0__oN Avatar answered Sep 18 '22 15:09

A0__oN


When using Maven, add the following snippet to <executions> of kotlin-maven-plugin.

<execution>
   <id>kapt</id>
   <goals>
      <goal>kapt</goal>
   </goals>
   <configuration>
      <sourceDirs>
         <sourceDir>src/main/kotlin</sourceDir>
      </sourceDirs>
      <annotationProcessorPaths>
         <annotationProcessorPath>
            <groupId>org.hibernate</groupId>
            <artifactId>hibernate-jpamodelgen</artifactId>
            <version>5.3.2.Final</version>
         </annotationProcessorPath>
      </annotationProcessorPaths>
   </configuration>
</execution>
like image 20
Juraj Mlich Avatar answered Sep 21 '22 15:09

Juraj Mlich