HHH-16967 Missing join on inheritance parent table to validate @Where condition

This commit is contained in:
Andrea Boriero 2023-11-17 16:02:35 +01:00 committed by Andrea Boriero
parent 166f6e685b
commit ed743a590d
2 changed files with 11 additions and 0 deletions

View File

@ -6718,4 +6718,8 @@ public abstract class AbstractEntityPersister
public String getDiscriminatorAlias() {
return DISCRIMINATOR_ALIAS;
}
protected String getSqlWhereStringTableExpression(){
return sqlWhereStringTableExpression;
}
}

View File

@ -1366,6 +1366,13 @@ public class JoinedSubclassEntityPersister extends AbstractEntityPersister {
if ( mainTableReference != null ) {
retainedTableReferences.add( mainTableReference );
}
final String sqlWhereStringTableExpression = persister.getSqlWhereStringTableExpression();
if ( sqlWhereStringTableExpression != null ) {
final TableReference tableReference = tableGroup.getTableReference( sqlWhereStringTableExpression );
if ( tableReference != null ) {
retainedTableReferences.add( tableReference );
}
}
if ( needsDiscriminator() ) {
// We allow multiple joined subclasses to use the same table if they define a discriminator column.
// In this case, we might need to add a discriminator condition to make sure we filter the correct subtype,