Problem with Set using lazy='false', fetch='join' and filters (with Criteria)

Description

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.

Environment

None

Attachments

1

Activity

Show:

Alex Zaytsev 
September 8, 2014 at 11:31 AM

Close issues resolved in 3.3.3

Oskar Berggren 
July 27, 2014 at 11:45 AM

I don't known when this was fixed, but the submitted test case succeeds since at least 3.3.3.GA (didn't test older releases). It also works on current 3.4.x and master branches.

Test case added to 3.4.x. branch in 7240908de2ab17dbf44b46f1c69919f4d6c11682.

Fabio Maulo 
July 4, 2009 at 12:21 PM

Title changed because it is working using HQL
from Customer c left join fetch c.Categories where c.Name = Name

Andrew Burgher 
July 1, 2009 at 10:43 PM

Attaching test case + mappings

Fixed

Details

Assignee

Reporter

Components

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
Who's Looking?