HHH-17885 Fix for same named attribute of different Embedded uses same selection expression

This commit is contained in:
Christian Beikov 2024-04-03 16:22:40 +02:00
parent 1fe26bc7f4
commit bcae77fb32
3 changed files with 10 additions and 6 deletions

View File

@ -305,7 +305,7 @@ public abstract class AbstractEmbeddableMapping implements EmbeddableMappingType
temporalPrecision = null; temporalPrecision = null;
nullable = true; nullable = true;
isLob = false; isLob = false;
selectablePath = basicValue.createSelectablePath( bootPropertyDescriptor.getName() ); selectablePath = new SelectablePath( determineEmbeddablePrefix() + bootPropertyDescriptor.getName() );
} }
attributeMapping = MappingModelCreationHelper.buildBasicAttributeMapping( attributeMapping = MappingModelCreationHelper.buildBasicAttributeMapping(
@ -457,6 +457,14 @@ public abstract class AbstractEmbeddableMapping implements EmbeddableMappingType
return true; return true;
} }
protected String determineEmbeddablePrefix() {
NavigableRole root = getNavigableRole().getParent();
while ( !root.isRoot() ) {
root = root.getParent();
}
return getNavigableRole().getFullPath().substring( root.getFullPath().length() + 1 ) + ".";
}
@Override @Override
public int getNumberOfFetchables() { public int getNumberOfFetchables() {
return getAttributeMappings().size(); return getAttributeMappings().size();

View File

@ -403,7 +403,7 @@ public class EmbeddableMappingTypeImpl extends AbstractEmbeddableMapping impleme
temporalPrecision = null; temporalPrecision = null;
isLob = false; isLob = false;
nullable = bootPropertyDescriptor.isOptional(); nullable = bootPropertyDescriptor.isOptional();
selectablePath = basicValue.createSelectablePath( bootPropertyDescriptor.getName() ); selectablePath = new SelectablePath( determineEmbeddablePrefix() + bootPropertyDescriptor.getName() );
} }
attributeMapping = MappingModelCreationHelper.buildBasicAttributeMapping( attributeMapping = MappingModelCreationHelper.buildBasicAttributeMapping(
bootPropertyDescriptor.getName(), bootPropertyDescriptor.getName(),

View File

@ -106,10 +106,6 @@ public final class NavigableRole implements DotIdentifierSequence, Serializable
return fullPath; return fullPath;
} }
public boolean isRoot() {
return parent == null && StringHelper.isEmpty( localName );
}
@Override @Override
public String toString() { public String toString() {
return getClass().getSimpleName() + '[' + fullPath + ']'; return getClass().getSimpleName() + '[' + fullPath + ']';