DefaultRevisionEntity: java.lang.IllegalArgumentException: Can not set static jakarta.persistence.metamodel.MappedSuperclassType field org.hibernate.envers.DefaultRevisionEntity_.class_ to org.hibernate.metamodel.model.domain.internal.EntityTypeImpl

Hey everyone,

we are using hibernate envers version 6.4.1.Final.
We setup a table “revinfo” and the respective _aud tables for all auditable entities. The auditing is behaving as should.

On the startup of the service, we are receiving an exception:

 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

Now, I digged a bit deeper into the MetaDataContext to get the following error message:

java.lang.IllegalArgumentException: Can not set static jakarta.persistence.metamodel.MappedSuperclassType field org.hibernate.envers.DefaultRevisionEntity_.class_ to org.hibernate.metamodel.model.domain.internal.EntityTypeImpl

We do not have a custom implementation of the DefaultRevisionEntity. When i add one, the error messages above are gone.

Now I wondered, why this exception is triggered and if this is a desired behavior.

Thanks, already for the response!

2 Likes

hi,
we have the same issue with hibernate envers 6.4.1.Final built in spring-data-envers 3.2.1

thanks for your help

Hi Martin, i have the same issue with version 6.4.1 Final

Please try to create a reproducer with our test case template (hibernate-test-case-templates/orm/hibernate-orm-6/src/test/java/org/hibernate/bugs/JPAUnitTestCase.java at main · hibernate/hibernate-test-case-templates · GitHub) and if you are able to reproduce the issue, create a bug ticket in our issue tracker(https://hibernate.atlassian.net) and attach that reproducer.

This is raised in the issue tracker here:
https://hibernate.atlassian.net/browse/HHH-17612

2 Likes

I’ve ran into the same problem after upgrading to Spring 3.2.1 to resolve reported vulnerabilities. Downgraded to version 6.2.6.Final of hibernate-core and hibernate-envers fixed the problem for me.

1 Like