When upgrading an application from Hibernate 5.6 to 6.2 I ran into an issue where the class corresponding to an @Embedded property was not annotated with @Embeddable I am also using the enhance maven plugin:
<plugin>
<groupId>org.hibernate.orm.tooling</groupId>
<artifactId>hibernate-enhance-maven-plugin</artifactId>
<version>${hibernate.version}</version>
<executions>
<execution>
<configuration>
<failOnError>true</failOnError>
<enableLazyInitialization>false</enableLazyInitialization>
<enableDirtyTracking>true</enableDirtyTracking>
<enableAssociationManagement>false</enableAssociationManagement>
<enableExtendedEnhancement>false</enableExtendedEnhancement>
</configuration>
<goals>
<goal>enhance</goal>
</goals>
</execution>
</executions>
</plugin>
With Hibernate 6 this fails at runtime when trying to call the property setter:
Unless I’m mistaken it is indeed requirred by the JPA spec that the class is annotated with @Embeddable so it is user error and it is fair enough that it fails. However the error message (and the cause of the problem) was not so obvious to me, I found solution from someone who ran into a similar problem: https://github.com/quarkusio/quarkus/issues/34603 Maybe this should fail at build time, when running the bytecode enhancement? Or maybe the error message could mention @Embeddable as a possible cause for the error? I’ve tried making a unit test reproducing the problem but could not, so maybe I misunderstood the issue. |