HHH-17119 Avoid type pollution when casting ModelPart to EntityMappingType

This commit is contained in:
Sanne Grinovero 2023-08-22 16:14:40 +02:00 committed by Sanne Grinovero
parent a6d1bea5b9
commit 062b8bcd68
3 changed files with 11 additions and 1 deletions

View File

@ -104,6 +104,11 @@ public interface EntityMappingType
return getMappedJavaType();
}
@Override
default EntityMappingType asEntityMappingType() {
return this;
}
@Override
default MappingType getPartMappingType() {
return this;

View File

@ -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}.

View File

@ -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;