Skip to content

Commit deaa8f0

Browse files
David EllingsworthDavid Ellingsworth
David Ellingsworth
authored and
David Ellingsworth
committed
[GH-2201] Only check collections for duplicate joins.
1 parent df292f1 commit deaa8f0

File tree

2 files changed

+11
-19
lines changed

2 files changed

+11
-19
lines changed

src/NHibernate/Loader/Criteria/CriteriaJoinWalker.cs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -208,7 +208,10 @@ protected override JoinType GetJoinType(IAssociationType type, FetchMode config,
208208
case SelectMode.FetchLazyPropertyGroup:
209209
case SelectMode.ChildFetch:
210210
case SelectMode.JoinOnly:
211-
IsDuplicateAssociation(lhsTable, lhsColumns, type); //deliberately ignore return value!
211+
if (type.IsCollectionType)
212+
{
213+
IsDuplicateAssociation(lhsTable, lhsColumns, type); //deliberately ignore return value!
214+
}
212215
return GetJoinType(nullable, currentDepth);
213216

214217
case SelectMode.Skip:

src/NHibernate/Loader/JoinWalker.cs

Lines changed: 7 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -605,9 +605,13 @@ protected virtual JoinType GetJoinType(IAssociationType type, FetchMode config,
605605
if (IsTooDeep(currentDepth) || (type.IsCollectionType && IsTooManyCollections))
606606
return JoinType.None;
607607

608-
bool dupe = IsDuplicateAssociation(lhsTable, lhsColumns, type);
609-
if (dupe)
610-
return JoinType.None;
608+
if (type.IsCollectionType)
609+
{
610+
if(IsDuplicateAssociation(lhsTable, lhsColumns, type))
611+
{
612+
return JoinType.None;
613+
}
614+
}
611615

612616
return GetJoinType(nullable, currentDepth);
613617
}
@@ -791,21 +795,6 @@ public override int GetHashCode()
791795
}
792796
}
793797

794-
/// <summary>
795-
/// Should we join this association?
796-
/// </summary>
797-
protected bool IsJoinable(JoinType joinType, ISet<AssociationKey> visitedAssociationKeys, string lhsTable,
798-
string[] lhsColumnNames, IAssociationType type, int depth)
799-
{
800-
if (joinType < JoinType.InnerJoin) return false;
801-
if (joinType == JoinType.InnerJoin) return true;
802-
803-
int maxFetchDepth = Factory.Settings.MaximumFetchDepth;
804-
bool tooDeep = maxFetchDepth >= 0 && depth >= maxFetchDepth;
805-
806-
return !tooDeep && !IsDuplicateAssociation(lhsTable, lhsColumnNames, type);
807-
}
808-
809798
protected SqlString OrderBy(IList<OuterJoinableAssociation> associations, SqlString orderBy)
810799
{
811800
return MergeOrderings(OrderBy(associations), orderBy);

0 commit comments

Comments
 (0)