Hibernate Envers 6.4.1: Illegal argument on static metamodel field injection

1.3k Views Asked by At

I migrate to Hibernate 6.4.1 (via spring boot 3.2.1) and my app logs an error that wasnt' there before:

2024-01-03T15:49:10.361+01:00 ERROR 81857 --- [           main] 
o.h.metamodel.internal.MetadataContext   : 
HHH015007: Illegal argument on static metamodel field injection : 
org.hibernate.envers.DefaultRevisionEntity_#class_; expected type :  
org.hibernate.metamodel.model.domain.internal.EntityTypeImpl; encountered type : 
jakarta.persistence.metamodel.MappedSuperclassType

I can reproduce this with a minimal example by basically copying the code from spring data envers documentation: https://docs.spring.io/spring-data/jpa/reference/envers/configuration.html

I can also reproduce this by running the spring-data-envers example: https://github.com/spring-projects/spring-data-examples/blob/main/jpa/envers/pom.xml

I can also reproduce this by running https://github.com/hibernate/hibernate-orm/blob/main/hibernate-envers/src/test/java/org/hibernate/orm/test/envers/DefaultAuditTest.java

Created issue https://hibernate.atlassian.net/jira/software/c/projects/HHH/boards/31?selectedIssue=HHH-17612

2

There are 2 best solutions below

0
IGNACIO ARAUJO On

In my case, using the @Audited annotation of hibernate envers caused the error. I resolved the error by removing the dependency implementation "org.hibernate:hibernate-envers" and adding implementation "org.hibernate:hibernate-envers-jakarta:5.6.15.Final".

0
Eric On

I have the same issue, and I flipped out at first, but taking a closer look at the code, it seems that this used to be a hard fail but now it's only logged as error-- Once I realized that, I sort of kept my fingers crossed and hoped that everything would work anyway. While it would definitely make me feel better if the error went away, so far it hasn't impacted the behavior of my code.