Embeddable type cannot be cast to org.hibernate.usertype.CompositeUserType if referred to from a mapped superclass with generic parameter
Description
Trying to upgrade a project from Hibernate 5 to 6 I run into the following issue:
The rough arrangement looks like this (pseudocode):
org.hibernate.cfg.ClassPropertyHolder.addPropertyToMappedSuperclass(Property, XClass) runs into a special branch of the code if the mapped superclass has generic parameters. In that case, it ultimately ends up calling setTypeName(…) with the type name of the embeddable as parameter. ComponentType later inspects that type name and tries to resolve it in its constructor, unconditionally casting it to CompositeUserType.
Trying to upgrade a project from Hibernate 5 to 6 I run into the following issue:
The rough arrangement looks like this (pseudocode):
org.hibernate.cfg.ClassPropertyHolder.addPropertyToMappedSuperclass(Property, XClass)
runs into a special branch of the code if the mapped superclass has generic parameters. In that case, it ultimately ends up callingsetTypeName(…)
with the type name of the embeddable as parameter.ComponentType
later inspects that type name and tries to resolve it in its constructor, unconditionally casting it toCompositeUserType
.Find a reproducer here.
Hope that helps further diagnosing the problem.