HHH-17629 Reuse compatible joins for entity graphs and fetch profiles
This commit is contained in:
parent
3b0ec32162
commit
e8b5a23dd2
|
@ -8148,8 +8148,15 @@ public abstract class BaseSqmToSqlAstConverter<T extends Statement> extends Base
|
|||
fetchablePath,
|
||||
np -> {
|
||||
// generate the join
|
||||
final TableGroup tableGroup;
|
||||
final TableGroup lhs = fromClauseIndex.getTableGroup( fetchParent.getNavigablePath() );
|
||||
final TableGroupJoin tableGroupJoin = ( (TableGroupJoinProducer) fetchable ).createTableGroupJoin(
|
||||
final TableGroupJoinProducer joinProducer = (TableGroupJoinProducer) fetchable;
|
||||
final TableGroup compatibleTableGroup = lhs.findCompatibleJoinedGroup(
|
||||
joinProducer,
|
||||
joinProducer.determineSqlJoinType( lhs, null, true )
|
||||
);
|
||||
if ( compatibleTableGroup == null ) {
|
||||
final TableGroupJoin tableGroupJoin = joinProducer.createTableGroupJoin(
|
||||
fetchablePath,
|
||||
lhs,
|
||||
alias,
|
||||
|
@ -8160,9 +8167,14 @@ public abstract class BaseSqmToSqlAstConverter<T extends Statement> extends Base
|
|||
BaseSqmToSqlAstConverter.this
|
||||
);
|
||||
lhs.addTableGroupJoin( tableGroupJoin );
|
||||
tableGroup = tableGroupJoin.getJoinedGroup();
|
||||
}
|
||||
else {
|
||||
tableGroup = compatibleTableGroup;
|
||||
}
|
||||
|
||||
// and return the joined group
|
||||
return tableGroupJoin.getJoinedGroup();
|
||||
return tableGroup;
|
||||
}
|
||||
);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue