Skip to content

Commit 9d52e3c

Browse files
committed
HHH-18819 Fix metamodel of id-class extending from mapped-superclasses
1 parent 92e4977 commit 9d52e3c

File tree

1 file changed

+16
-7
lines changed

1 file changed

+16
-7
lines changed

hibernate-core/src/main/java/org/hibernate/metamodel/internal/MetadataContext.java

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -575,15 +575,24 @@ private Property getMappedSuperclassIdentifier(PersistentClass persistentClass)
575575
return null;
576576
}
577577

578-
private EmbeddableTypeImpl<?> applyIdClassMetadata(Component idClassComponent) {
579-
final JavaTypeRegistry registry = getTypeConfiguration()
580-
.getJavaTypeRegistry();
581-
final Class<?> componentClass = idClassComponent.getComponentClass();
582-
final JavaType<?> javaType = registry.resolveManagedTypeDescriptor( componentClass );
578+
private <Y> EmbeddableTypeImpl<Y> applyIdClassMetadata(Component idClassComponent) {
579+
final JavaType<Y> javaType =
580+
getTypeConfiguration().getJavaTypeRegistry()
581+
.resolveManagedTypeDescriptor( idClassComponent.getComponentClass() );
582+
583+
final MappedSuperclass mappedSuperclass = idClassComponent.getMappedSuperclass();
584+
final MappedSuperclassDomainType<? super Y> superType;
585+
if ( mappedSuperclass != null ) {
586+
//noinspection unchecked
587+
superType = (MappedSuperclassDomainType<? super Y>) locateMappedSuperclassType( mappedSuperclass );
588+
}
589+
else {
590+
superType = null;
591+
}
583592

584-
final EmbeddableTypeImpl<?> embeddableType = new EmbeddableTypeImpl<>(
593+
final EmbeddableTypeImpl<Y> embeddableType = new EmbeddableTypeImpl<>(
585594
javaType,
586-
null,
595+
superType,
587596
null,
588597
false,
589598
getJpaMetamodel()

0 commit comments

Comments
 (0)