Skip to content

Commit

Permalink
Fix
Browse files Browse the repository at this point in the history
  • Loading branch information
bahusoid committed Aug 5, 2023
1 parent 849b031 commit 7c31eb5
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions src/NHibernate/Loader/JoinWalker.cs
Original file line number Diff line number Diff line change
Expand Up @@ -347,11 +347,6 @@ private void WalkCollectionTree(IQueryableCollection persister, string alias, st
string[] aliasedLhsColumns = persister.GetElementColumnNames(alias);
string[] lhsColumns = persister.ElementColumnNames;

// if the current depth is 0, the root thing being loaded is the
// many-to-many collection itself. Here, it is alright to use
// an inner join...
bool useInnerJoin = _depth == 0;

var joinType =
GetJoinType(
associationType,
Expand All @@ -360,10 +355,16 @@ private void WalkCollectionTree(IQueryableCollection persister, string alias, st
pathAlias,
persister.TableName,
lhsColumns,
!useInnerJoin,
false,
_depth - 1,
null);

// It's safe to always use inner join for many-to-many not-found ignore mapping as it's processed by table group join;
// otherwise we need left join for proper not-found exception handling
if (joinType == JoinType.LeftOuterJoin && ((EntityType) type).IsNullable)
joinType = JoinType.InnerJoin;


AddAssociationToJoinTreeIfNecessary(
associationType,
aliasedLhsColumns,
Expand Down

0 comments on commit 7c31eb5

Please sign in to comment.