Skip to content

Commit 15fd989

Browse files
committed
HHH-17885 Fix for same named attribute of different Embedded uses same selection expression
1 parent 62836b5 commit 15fd989

File tree

3 files changed

+10
-6
lines changed

3 files changed

+10
-6
lines changed

hibernate-core/src/main/java/org/hibernate/metamodel/mapping/internal/AbstractEmbeddableMapping.java

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -302,7 +302,7 @@ protected boolean finishInitialization(
302302
scale = null;
303303
nullable = true;
304304
isLob = false;
305-
selectablePath = basicValue.createSelectablePath( bootPropertyDescriptor.getName() );
305+
selectablePath = new SelectablePath( determineEmbeddablePrefix() + bootPropertyDescriptor.getName() );
306306
}
307307

308308
attributeMapping = MappingModelCreationHelper.buildBasicAttributeMapping(
@@ -453,6 +453,14 @@ else if ( subtype instanceof EntityType ) {
453453
return true;
454454
}
455455

456+
protected String determineEmbeddablePrefix() {
457+
NavigableRole root = getNavigableRole().getParent();
458+
while ( !root.isRoot() ) {
459+
root = root.getParent();
460+
}
461+
return getNavigableRole().getFullPath().substring( root.getFullPath().length() + 1 ) + ".";
462+
}
463+
456464
@Override
457465
public int getNumberOfFetchables() {
458466
return getAttributeMappings().size();

hibernate-core/src/main/java/org/hibernate/metamodel/mapping/internal/EmbeddableMappingTypeImpl.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -398,7 +398,7 @@ private boolean finishInitialization(
398398
scale = null;
399399
isLob = false;
400400
nullable = bootPropertyDescriptor.isOptional();
401-
selectablePath = basicValue.createSelectablePath( bootPropertyDescriptor.getName() );
401+
selectablePath = new SelectablePath( determineEmbeddablePrefix() + bootPropertyDescriptor.getName() );
402402
}
403403
attributeMapping = MappingModelCreationHelper.buildBasicAttributeMapping(
404404
bootPropertyDescriptor.getName(),

hibernate-core/src/main/java/org/hibernate/metamodel/model/domain/NavigableRole.java

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -106,10 +106,6 @@ public String getFullPath() {
106106
return fullPath;
107107
}
108108

109-
public boolean isRoot() {
110-
return parent == null && StringHelper.isEmpty( localName );
111-
}
112-
113109
@Override
114110
public String toString() {
115111
return getClass().getSimpleName() + '[' + fullPath + ']';

0 commit comments

Comments
 (0)