HHH-16166 Correct Plural and ToOne attribute mapping declaring types

This commit is contained in:
Marco Belladelli 2023-03-15 16:36:20 +01:00 committed by Christian Beikov
parent 52e1026b72
commit b0b1fbbff7
4 changed files with 7 additions and 11 deletions

View File

@ -397,15 +397,12 @@ public abstract class AbstractEmbeddableMapping implements EmbeddableMappingType
columnPosition += columnSpan;
}
else if ( subtype instanceof CollectionType ) {
final EntityPersister entityPersister = creationProcess.getEntityPersister( bootDescriptor.getOwner()
.getEntityName() );
attributeMapping = MappingModelCreationHelper.buildPluralAttributeMapping(
bootPropertyDescriptor.getName(),
attributeIndex,
attributeIndex,
bootPropertyDescriptor,
entityPersister,
this,
propertyAccess,
compositeType.getCascadeStyle( attributeIndex ),
compositeType.getFetchMode( attributeIndex ),
@ -422,7 +419,7 @@ public abstract class AbstractEmbeddableMapping implements EmbeddableMappingType
attributeIndex,
attributeIndex,
bootPropertyDescriptor,
entityPersister,
this,
entityPersister,
(EntityType) subtype,
representationStrategy.resolvePropertyAccess( bootPropertyDescriptor ),

View File

@ -496,14 +496,12 @@ public class EmbeddableMappingTypeImpl extends AbstractEmbeddableMapping impleme
columnPosition += columnSpan;
}
else if ( subtype instanceof CollectionType ) {
final EntityPersister entityPersister = creationProcess.getEntityPersister( bootDescriptor.getOwner().getEntityName() );
attributeMapping = MappingModelCreationHelper.buildPluralAttributeMapping(
bootPropertyDescriptor.getName(),
attributeIndex,
attributeIndex,
bootPropertyDescriptor,
entityPersister,
this,
representationStrategy.resolvePropertyAccess( bootPropertyDescriptor ),
compositeType.getCascadeStyle( attributeIndex),
compositeType.getFetchMode( attributeIndex ),
@ -519,7 +517,7 @@ public class EmbeddableMappingTypeImpl extends AbstractEmbeddableMapping impleme
attributeIndex,
attributeIndex,
bootPropertyDescriptor,
entityPersister,
this,
entityPersister,
(EntityType) subtype,
getRepresentationStrategy().resolvePropertyAccess( bootPropertyDescriptor ),

View File

@ -718,7 +718,7 @@ public class MappingModelCreationHelper {
fkTargetPart = collectionDescriptor.getOwnerEntityPersister().getIdentifierMapping();
}
else {
fkTargetPart = declaringType.findAttributeMapping( lhsPropertyName );
fkTargetPart = declaringType.findContainingEntityMapping().findAttributeMapping( lhsPropertyName );
}
if ( keyType instanceof BasicType ) {

View File

@ -84,7 +84,8 @@ public interface Initializer {
if ( entityInitializer != null ) {
final EntityPersister concreteDescriptor = entityInitializer.getConcreteDescriptor();
if ( concreteDescriptor.getEntityMetamodel().isPolymorphic() ) {
final EntityPersister declaringType = (EntityPersister) referencedModelPart.getDeclaringType();
final EntityPersister declaringType = (EntityPersister) referencedModelPart.getDeclaringType()
.findContainingEntityMapping();
if ( concreteDescriptor != declaringType ) {
return declaringType.getSubclassEntityNames().contains( concreteDescriptor.getEntityName() );
}