Skip to content

Commit a82fe2d

Browse files
committed
HHH-19457 Ignore joined discriminator when selecting all subtypes
1 parent 64fd538 commit a82fe2d

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
@@ -1437,15 +1437,16 @@ private boolean applyDiscriminatorPredicate(
14371437
Map<String, EntityNameUse> entityNameUses,
14381438
MappingMetamodelImplementor metamodel) {
14391439
if ( tableReference.getTableExpression().equals( getRootTableName() ) ) {
1440-
assert join.getJoinType() == SqlAstJoinType.INNER : "Found table reference join with root table of non-INNER type: " + join.getJoinType();
14411440
final String discriminatorPredicate = getPrunedDiscriminatorPredicate(
14421441
entityNameUses,
14431442
metamodel,
14441443
"t"
1445-
// tableReference.getIdentificationVariable()
14461444
);
1447-
tableReference.setPrunedTableExpression( "(select * from " + getRootTableName() + " t where " + discriminatorPredicate + ")" );
1448-
// join.applyPredicate( new SqlFragmentPredicate( discriminatorPredicate ) );
1445+
// null means we're filtering for all subtypes, so we don't need to apply a predicate
1446+
if ( discriminatorPredicate != null ) {
1447+
assert join.getJoinType() == SqlAstJoinType.INNER : "Found table reference join with root table of non-INNER type: " + join.getJoinType();
1448+
tableReference.setPrunedTableExpression( "(select * from " + getRootTableName() + " t where " + discriminatorPredicate + ")" );
1449+
}
14491450
return true;
14501451
}
14511452
return false;

0 commit comments

Comments
 (0)