diff --git a/hibernate-core/src/main/java/org/hibernate/metamodel/mapping/EntityMappingType.java b/hibernate-core/src/main/java/org/hibernate/metamodel/mapping/EntityMappingType.java index db305ff9c5..0dc6274529 100644 --- a/hibernate-core/src/main/java/org/hibernate/metamodel/mapping/EntityMappingType.java +++ b/hibernate-core/src/main/java/org/hibernate/metamodel/mapping/EntityMappingType.java @@ -104,6 +104,11 @@ public interface EntityMappingType return getMappedJavaType(); } + @Override + default EntityMappingType asEntityMappingType() { + return this; + } + @Override default MappingType getPartMappingType() { return this; diff --git a/hibernate-core/src/main/java/org/hibernate/metamodel/mapping/ModelPart.java b/hibernate-core/src/main/java/org/hibernate/metamodel/mapping/ModelPart.java index a2ee291286..c10fa072d3 100644 --- a/hibernate-core/src/main/java/org/hibernate/metamodel/mapping/ModelPart.java +++ b/hibernate-core/src/main/java/org/hibernate/metamodel/mapping/ModelPart.java @@ -142,6 +142,10 @@ public interface ModelPart extends MappingModelExpressible { return null; } + default EntityMappingType asEntityMappingType(){ + return null; + } + /** * A short hand form of {@link #breakDownJdbcValues(Object, int, Object, Object, JdbcValueBiConsumer, SharedSessionContractImplementor)}, * that passes 0 as offset and null for the two values {@code X} and {@code Y}. diff --git a/hibernate-core/src/main/java/org/hibernate/sql/results/graph/entity/AbstractEntityInitializer.java b/hibernate-core/src/main/java/org/hibernate/sql/results/graph/entity/AbstractEntityInitializer.java index 913755bd7d..265166c2fc 100644 --- a/hibernate-core/src/main/java/org/hibernate/sql/results/graph/entity/AbstractEntityInitializer.java +++ b/hibernate-core/src/main/java/org/hibernate/sql/results/graph/entity/AbstractEntityInitializer.java @@ -172,7 +172,8 @@ public abstract class AbstractEntityInitializer extends AbstractFetchParentAcces : fetch.createAssembler( this, creationState ); final int stateArrayPosition = attributeMapping.getStateArrayPosition(); - final EntityMappingType declaringType = (EntityMappingType) attributeMapping.getDeclaringType(); + final EntityMappingType declaringType = attributeMapping.getDeclaringType().asEntityMappingType(); + assemblers[declaringType.getSubclassId()][stateArrayPosition] = stateAssembler; for ( EntityMappingType subMappingType : declaringType.getSubMappingTypes() ) { assemblers[subMappingType.getSubclassId()][stateArrayPosition] = stateAssembler;