– Start
为了使用查询接口 Criteria,我们需要生成实体类的元模型(Metamodel),怎么生成呢?最常用的是通过 Maven 来自动生成。
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.7.0</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
<annotationProcessorPaths>
<path>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-jpamodelgen</artifactId>
<version>5.4.3.Final</version>
</path>
</annotationProcessorPaths>
<generatedSourcesDirectory>target/metamodel</generatedSourcesDirectory>
</configuration>
</plugin>
</plugins>
</build>