Search code examples
spring-bootspring-data-jpajava-17hibernate-6.x

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


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>

Solution

  • 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