Fixed
Details
Details
Assignee
Unassigned
UnassignedReporter
Andrew Burgher
Andrew BurgherComponents
Fix versions
Affects versions
Priority
Who's Looking?
Open Who's Looking?
Created July 1, 2009 at 10:39 PM
Updated September 8, 2014 at 11:31 AM
Resolved July 27, 2014 at 11:45 AM
Using NH trunk we have a problem with the SQL generated in a scenario like this:
1. Customer is assigned 0..M Categories (<set lazy='false' fetch = 'join' ... )
2. Categories can be active / inactive (<filter name='onlyActive' condition=':activeFlag = IsActive' />)
Things are OK when the customer has at least one category, but is unable to return a customer that has no categories. The resulting SQL looks something like this:
SELECT
...
FROM
Customer this_
left outer join Category categories2_ on this_.Id=categories2_.Category_Id and @p0 = categories2_.IsActive
WHERE
@p1 = categories2_.IsActive <== This is going to prevent us getting a Customer with no Categories
AND this_.Name = @p2',
The filter clause should really only be appearing on the outer join.
Have narrowed the problem down to the changes made to NHibernate.Loader.JoinWalker.cs (MergeOuterJoins) as part of revision 4276 (Fix for NH-1179). Those changes appear to have been added to support filters for a many-to-one association - but are now causing this problem for one-to-many associations that use the join fetch method.