Guillaume Toison (
https://hibernate.atlassian.net/secure/ViewProfile.jspa?accountId=70121%3...
) *created* an issue
Hibernate ORM (
https://hibernate.atlassian.net/browse/HHH?atlOrigin=eyJpIjoiYzM4NWQxMTQ0...
) / Bug (
https://hibernate.atlassian.net/browse/HHH-16952?atlOrigin=eyJpIjoiYzM4NW...
) HHH-16952 (
https://hibernate.atlassian.net/browse/HHH-16952?atlOrigin=eyJpIjoiYzM4NW...
) Bytecode enhancement now requires embedded component to be @Embeddable (
https://hibernate.atlassian.net/browse/HHH-16952?atlOrigin=eyJpIjoiYzM4NW...
)
Issue Type: Bug Affects Versions: 6.2.6 Assignee: Unassigned Components: hibernate-core,
hibernate-enhance-maven-plugin Created: 18/Jul/2023 00:04 AM Priority: Minor Reporter:
Guillaume Toison (
https://hibernate.atlassian.net/secure/ViewProfile.jspa?accountId=70121%3...
)
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:
java.lang.ClassCastException: Object of type 'class abc.MyComponent' can't be
cast to CompositeTracker
at
org.hibernate.engine.internal.ManagedTypeHelper.asCompositeTracker(ManagedTypeHelper.java:337)
at abc.MyEntity.$$_hibernate_write_myEmbeddedProperty(MyEntity.java)
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.
(
https://hibernate.atlassian.net/browse/HHH-16952#add-comment?atlOrigin=ey...
) Add Comment (
https://hibernate.atlassian.net/browse/HHH-16952#add-comment?atlOrigin=ey...
)
Get Jira notifications on your phone! Download the Jira Cloud app for Android (
https://play.google.com/store/apps/details?id=com.atlassian.android.jira....
) or iOS (
https://itunes.apple.com/app/apple-store/id1006972087?pt=696495&ct=Em...
) This message was sent by Atlassian Jira (v1001.0.0-SNAPSHOT#100232- sha1:4a3b42c )