spring-projects / spring-data-jpa

Simplifies the development of creating a JPA-based data access layer.
https://spring.io/projects/spring-data-jpa/
Apache License 2.0
2.93k stars 1.39k forks source link

Spring Boot 3.2.x with @Audited annotation is causing Hibernate error at application startup #3381

Closed dietzsch closed 4 months ago

dietzsch commented 4 months ago

Hello,

we recently updated from Spring Boot 3.1.x to 3.2.x. In parallel we are using @Audited and have a dependency:

org.hibernate.orm:hibernate-envers

After the update to the new Spring Boot version we see the following error at startup of the application:

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

which seems to be related to the envers dependency. There is also already a thread on Stackoverflow that is discussing this issue:

https://stackoverflow.com/questions/77753483/hibernate-envers-6-4-1-illegal-argument-on-static-metamodel-field-injection

Alex

christophstrobl commented 4 months ago

Thank you @dietzsch for the heads up!

mp911de commented 4 months ago

If you would like us to spend some time helping you to diagnose the problem, please spend some time describing it and, ideally, providing a minimal yet complete sample that reproduces the problem. You can share it with us by pushing it to a separate repository on GitHub or by zipping it up and attaching it to this issue.

mp911de commented 4 months ago

FTR: Upgrading https://github.com/spring-projects/spring-data-examples/blob/main/jpa/envers/pom.xml to Hibernate 6.4.1 should also reproduce the failure.

dietzsch commented 4 months ago

Hi @mp911de I used the code from the docs and created a minimal project where you can see the error when running the test. Repo: https://github.com/dietzsch/issue-3381

dietzsch commented 4 months ago

PS: I used the current Spring Boot 3.2.3 version with Hibernate 6.4.4.Final

mp911de commented 4 months ago

org.hibernate.metamodel.model.domain.internal.EntityTypeImpl does not jakarta.persistence.metamodel.MappedSuperclassType. This is a Hibernate issue that I can reproduce with the plain Hibernate reproducer testcase by just adding Hibernate envers.

See https://gist.github.com/mp911de/1d5231ab2fb64356b35130f3f41fdf8b

krzyk commented 2 months ago

Was this issue reported to Hibernate? If so it would be good to link it here, as this issue is first that shows up in search results.

minikolic commented 1 month ago

@krzyk there is open issue on hibernate: https://hibernate.atlassian.net/browse/HHH-17612