Supported source version 'RELEASE_6' for 'org.hibernate.jpamodelgen.JPAMetaModelEntityProcessor' is lower than -source '1.8'

 Running a project found an error that the class could not be found and issued a warning: The supported source version 'RELEASE_6' from the annotation processor 'org.hibernate.jpamodelgen.JPAMetaModelEntityProcessor' is lower than -source '1.8', and the class ends with an underscore (class name Underline | ORM object underline), is the Metamodel usage of JPA.

What is Metamodel

If you use JPA or Hibernate to write criteriaQuery.

You may come across the following sentence

criteriaQuery.where(builder.greaterThan(root.get("dateM"), new DateTime().minusDays(100).toDate()));

Regardless of all the above type definitions, the meaning of the above sentence is to create a SQL query dateM field update time is greater than the current time minus 100 days.

If you use Metamodel, it can be written as:

criteriaQuery.where(builder.greaterThan(root.get(MlsListing_.DATE_M), new DateTime().minusDays(100).toDate()));

The above sentence queries the update date in the MlsListing_ORM object, which is equivalent to the above sentence.

MlsListing_.DATE_MIt is what we call Metamodel, which is dynamically generated.

And it uses the underlined expression of the ORM object.

Solution: Just configure Annotation Processors in IDEA

  In the annotation processor configuration, enable annotation processing and select obtain from project classpath. Add the annotation processor name org.hibernate.jpamodelgen.JPAMetaModelEntityProcessor (and optionally the annotation processor options). Select the module(s) containing your entities. If you have configured Maven as recommended, it is best to select the same output directory for the generated classes. At the time of writing, it is target/generated-sources/apt. That way, the generated classes will be available in IntelliJ Idea.

Reference article:

1.JPA Static Metamodel Generator

2. JPA 的 Metamodel - Java - OSSEZ

Supongo que te gusta

Origin blog.csdn.net/m0_75186659/article/details/128301734
Recomendado
Clasificación