Skip to content

Commit 96e180e

Browse files
committed
HHH-19457 Ignore joined discriminator when selecting all subtypes
1 parent 2160b5f commit 96e180e

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

hibernate-core/src/main/java/org/hibernate/persister/entity/JoinedSubclassEntityPersister.java

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1293,15 +1293,16 @@ private boolean applyDiscriminatorPredicate(
12931293
Map<String, EntityNameUse> entityNameUses,
12941294
MappingMetamodelImplementor metamodel) {
12951295
if ( tableReference.getTableExpression().equals( getRootTableName() ) ) {
1296-
assert join.getJoinType() == SqlAstJoinType.INNER : "Found table reference join with root table of non-INNER type: " + join.getJoinType();
12971296
final String discriminatorPredicate = getPrunedDiscriminatorPredicate(
12981297
entityNameUses,
12991298
metamodel,
13001299
"t"
1301-
// tableReference.getIdentificationVariable()
13021300
);
1303-
tableReference.setPrunedTableExpression( "(select * from " + getRootTableName() + " t where " + discriminatorPredicate + ")" );
1304-
// join.applyPredicate( new SqlFragmentPredicate( discriminatorPredicate ) );
1301+
// null means we're filtering for all subtypes, so we don't need to apply a predicate
1302+
if ( discriminatorPredicate != null ) {
1303+
assert join.getJoinType() == SqlAstJoinType.INNER : "Found table reference join with root table of non-INNER type: " + join.getJoinType();
1304+
tableReference.setPrunedTableExpression( "(select * from " + getRootTableName() + " t where " + discriminatorPredicate + ")" );
1305+
}
13051306
return true;
13061307
}
13071308
return false;

0 commit comments

Comments
 (0)