JPA Metamodel doesn't generate sources after moving to spring boot 3 and java 17
Asked Answered
S

3

8

After moving the spring boot project from 2.0 to 3.0 and upgrading to java 17, hibernate-jpamodelgen doesn't generate a metamodel classes.

I added this dependency, but it still doesn't work. Could someone help?

<dependency>
     <groupId>org.hibernate.orm</groupId>
     <artifactId>hibernate-jpamodelgen</artifactId>
</dependency>
Standridge answered 17/5, 2023 at 22:0 Comment(0)
T
2

This may not be caused by hibernate-jpamodelgen itself. Check your build to make sure that the other annotation processors in your build are working correctly and there are no other compiler errors. For me, the metamodel classes were only generated after all of the other errors were resolved.

When I encountered this behavior after upgrading, I had @ContructorBinding annotations where they were no longer supported. Removing these bad annotations fixed the problem.

This source helped me figure out what was going on: A less expected way JPA metamodel generation can fail

Thromboplastic answered 5/9, 2023 at 17:10 Comment(3)
I had annotation in my code @org.hibernate.annotations.Type which caused this. I missed this errorr among other compilation errors related to absent metamodel class.Vitus
Hello, my project is correct building... but I can't import the Entity_ in my repository class. Do you know about it ? I also can see Entity_ in my target folder. I use Eclipse 2024.Compulsory
I can do it. it's for Eclipse. right click on the project and select properties, select java compiler ---> Annotation processing and active Enable project specific setting and add the address of BaseEntity_Compulsory
M
3

I simply added the path to it in my maven-compiler-plugin's annotationProcessorPaths and it generates the models without any problem.

See here what I did

<plugin>
  <groupId>org.apache.maven.plugins</groupId>
  <artifactId>maven-compiler-plugin</artifactId>
  <version>3.10.1</version>
  <configuration>
    <annotationProcessorPaths>
        <path>
            <groupId>org.hibernate.orm</groupId>
            <artifactId>hibernate-jpamodelgen</artifactId>
            <version>6.4.4.Final</version>
        </path>
    </annotationProcessorPaths>
  </configuration>
</plugin>

I didn't need to add the dependency since I have no use of this annotation processor in my code directly. Try it, it should work.

Mirellamirelle answered 10/6, 2024 at 8:38 Comment(0)
T
2

This may not be caused by hibernate-jpamodelgen itself. Check your build to make sure that the other annotation processors in your build are working correctly and there are no other compiler errors. For me, the metamodel classes were only generated after all of the other errors were resolved.

When I encountered this behavior after upgrading, I had @ContructorBinding annotations where they were no longer supported. Removing these bad annotations fixed the problem.

This source helped me figure out what was going on: A less expected way JPA metamodel generation can fail

Thromboplastic answered 5/9, 2023 at 17:10 Comment(3)
I had annotation in my code @org.hibernate.annotations.Type which caused this. I missed this errorr among other compilation errors related to absent metamodel class.Vitus
Hello, my project is correct building... but I can't import the Entity_ in my repository class. Do you know about it ? I also can see Entity_ in my target folder. I use Eclipse 2024.Compulsory
I can do it. it's for Eclipse. right click on the project and select properties, select java compiler ---> Annotation processing and active Enable project specific setting and add the address of BaseEntity_Compulsory
H
0

During the migration to Java 19 with Spring Boot 3.2.1, which utilizes Hibernate 6, I encountered an issue related to annotation processing. To resolve this, the following steps were taken:

Updated Dependency: The hibernate-jpamodelgen dependency was updated to the newer version. The updated dependency in the pom.xml file is as follows:

org.hibernate hibernate-jpamodelgen 6.4.1.Final provided

Modified Maven Compiler Plugin Configuration: The Maven Compiler Plugin was reconfigured to support Java 19, ensuring proper functioning of annotation processors. The revised plugin configuration is:

org.apache.maven.plugins maven-compiler-plugin 19 19 org.hibernate hibernate-jpamodelgen 6.4.1.Final

These changes ensured that other annotation processors in the build worked correctly and rectified the encountered issue.

Haffner answered 10/1, 2024 at 15:9 Comment(1)
Your answer could be improved with additional supporting information. Please edit to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers in the help center.Jotunheim

© 2022 - 2025 — McMap. All rights reserved.