Koitlin对JPA静态元模型的支持

Ama*_*har 5 metamodel kotlin jpa-2.1

当我Entity使用Java JPA 创建类时,会生成静态元模型。

如果我将实体转换为Kotlin JPA,则不会生成静态元模型。

如何解决这个问题呢?

编辑

我正在使用Gradle作为构建工具。

Jur*_*ich 7

使用 Maven 时,将以下代码片段添加到<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>
Run Code Online (Sandbox Code Playgroud)


Ama*_*har 5

我不得不使用kapt 插件

我必须在我的build.gradle文件中添加以下行。

kapt "org.hibernate:hibernate-jpamodelgen:${hibernate_version}"
Run Code Online (Sandbox Code Playgroud)