HHH-18503 Register root table name usage for persisters with physical discriminators

This commit is contained in:
Marco Belladelli 2024-08-20 10:29:57 +02:00
parent aae1ef9df0
commit 49cca414b9
1 changed files with 11 additions and 1 deletions

View File

@ -3022,10 +3022,20 @@ public abstract class BaseSqmToSqlAstConverter<T extends Statement> extends Base
parentType.getRootEntityDescriptor().getEntityName() parentType.getRootEntityDescriptor().getEntityName()
); );
} }
final EntityDiscriminatorMapping discriminator = parentType.getDiscriminatorMapping();
final String entityName;
if ( discriminator != null && discriminator.hasPhysicalColumn() && !parentType.getSubMappingTypes().isEmpty() ) {
// This is needed to preserve optimization for joined + discriminator inheritance
// see JoinedSubclassEntityPersister#getIdentifierMappingForJoin
entityName = parentType.getRootEntityDescriptor().getEntityName();
}
else {
entityName = parentType.getEntityName();
}
registerEntityNameUsage( registerEntityNameUsage(
tableGroup, tableGroup,
EntityNameUse.EXPRESSION, EntityNameUse.EXPRESSION,
parentType.getEntityName() entityName
); );
} }
else { else {