Skip to content

Commit 42e7ce8

Browse files
committed
HHH-17328 Add discriminator to entity graph with inheritance subtypes
1 parent b96fd92 commit 42e7ce8

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

hibernate-core/src/main/java/org/hibernate/query/sqm/sql/BaseSqmToSqlAstConverter.java

+9-3
Original file line numberDiff line numberDiff line change
@@ -8107,16 +8107,22 @@ else if ( getLoadQueryInfluencers().hasEnabledFetchProfiles() ) {
81078107
final TableGroup actualTableGroup = joinedTableGroup instanceof PluralTableGroup ?
81088108
( (PluralTableGroup) joinedTableGroup ).getElementTableGroup() :
81098109
joinedTableGroup;
8110-
final MappingType entityMappingType = actualTableGroup == null
8110+
final MappingType mappingType = actualTableGroup == null
81118111
? null
81128112
: actualTableGroup.getModelPart().getPartMappingType();
8113-
if ( entityMappingType instanceof EntityMappingType ) {
8113+
if ( mappingType instanceof EntityMappingType ) {
8114+
final EntityMappingType entityMappingType = (EntityMappingType) mappingType;
81148115
registerEntityNameUsage(
81158116
actualTableGroup,
81168117
EntityNameUse.PROJECTION,
8117-
( (EntityMappingType) entityMappingType ).getEntityName(),
8118+
entityMappingType.getEntityName(),
81188119
true
81198120
);
8121+
if ( entityMappingType.getSuperMappingType() != null ) {
8122+
// A joined table group was created by an enabled entity graph or fetch profile,
8123+
// and it's of an inheritance subtype, so we should apply the discriminator
8124+
entityMappingType.applyDiscriminator( null, null, actualTableGroup, this );
8125+
}
81208126
}
81218127
}
81228128
if ( fetchable instanceof PluralAttributeMapping ) {

0 commit comments

Comments
 (0)