1
1
using System ;
2
- using System . Collections . Generic ;
3
- using System . Collections . Specialized ;
4
2
using System . Linq ;
5
3
using System . Linq . Expressions ;
6
4
using NHibernate . Engine ;
@@ -22,13 +20,11 @@ public class AddJoinsReWriter : NhQueryModelVisitorBase, IIsEntityDecider, INhQu
22
20
private readonly ISessionFactoryImplementor _sessionFactory ;
23
21
private readonly MemberExpressionJoinDetector _memberExpressionJoinDetector ;
24
22
private readonly WhereJoinDetector _whereJoinDetector ;
25
- private JoinClause _currentJoin ;
26
- private bool ? _innerJoin ;
27
23
28
24
private AddJoinsReWriter ( ISessionFactoryImplementor sessionFactory , QueryModel queryModel )
29
25
{
30
26
_sessionFactory = sessionFactory ;
31
- var joiner = new Joiner ( queryModel , AddJoin ) ;
27
+ var joiner = new Joiner ( queryModel ) ;
32
28
_memberExpressionJoinDetector = new MemberExpressionJoinDetector ( this , joiner , _sessionFactory ) ;
33
29
_whereJoinDetector = new WhereJoinDetector ( this , joiner , _sessionFactory ) ;
34
30
}
@@ -66,30 +62,17 @@ public override void VisitNhHavingClause(NhHavingClause havingClause, QueryModel
66
62
67
63
public void VisitNhOuterJoinClause ( NhOuterJoinClause nhOuterJoinClause , QueryModel queryModel , int index )
68
64
{
69
- VisitJoinClause ( nhOuterJoinClause . JoinClause , false ) ;
65
+ VisitJoinClause ( nhOuterJoinClause . JoinClause ) ;
70
66
}
71
67
72
68
public override void VisitJoinClause ( JoinClause joinClause , QueryModel queryModel , int index )
73
69
{
74
- VisitJoinClause ( joinClause , true ) ;
70
+ VisitJoinClause ( joinClause ) ;
75
71
}
76
72
77
- private void VisitJoinClause ( JoinClause joinClause , bool innerJoin )
73
+ private void VisitJoinClause ( JoinClause joinClause )
78
74
{
79
75
joinClause . InnerSequence = _whereJoinDetector . Transform ( joinClause . InnerSequence ) ;
80
-
81
- // When associations are located in the outer key (e.g. from a in A join b in B b on a.C.D.Id equals b.Id),
82
- // do nothing and leave them to HQL for adding the missing joins.
83
-
84
- // When associations are located in the inner key (e.g. from a in A join b in B b on a.Id equals b.C.D.Id),
85
- // we have to move the condition to the where statement, otherwise the query will be invalid (HQL does not
86
- // support them).
87
- // Link newly created joins with the current join clause in order to later detect which join type to use.
88
- _currentJoin = joinClause ;
89
- _innerJoin = innerJoin ;
90
- joinClause . InnerKeySelector = _whereJoinDetector . Transform ( joinClause . InnerKeySelector ) ;
91
- _currentJoin = null ;
92
- _innerJoin = null ;
93
76
}
94
77
95
78
// Since v5.3
@@ -107,18 +90,6 @@ public bool IsIdentifier(System.Type type, string propertyName)
107
90
return metadata != null && propertyName . Equals ( metadata . IdentifierPropertyName ) ;
108
91
}
109
92
110
- private void AddJoin ( QueryModel queryModel , NhJoinClause joinClause )
111
- {
112
- joinClause . ParentJoinClause = _currentJoin ;
113
- if ( _innerJoin == true )
114
- {
115
- // Match the parent join type
116
- joinClause . MakeInner ( ) ;
117
- }
118
-
119
- queryModel . BodyClauses . Add ( joinClause ) ;
120
- }
121
-
122
93
bool IIsEntityDecider . IsEntity ( MemberExpression expression , out bool isIdentifier )
123
94
{
124
95
isIdentifier =
0 commit comments