Skip to content

NH-3115 - Should de-duplicate joins when using fetching with where in LINQ query #871

Closed
@nhibernate-bot

Description

@nhibernate-bot

Andrey Kozhyn created an issue — 12th April 2012, 13:36:37:

This query:

var orderedQueryable = this.participationRequests
           .Fetch(x => x.CommunityEvent)
           .Fetch(x => x.CommunityMember)
                .ThenFetch(x => x.User)
           .Where(x => x.CommunityMember.Community.Id == communityId)
           .OrderBy(x => x.CreateDate);

Produces the following SQL:

select *
from   ParticipationRequests participat0_
       left outer join CommunityEvents communitye1_
         on participat0_.CommunityEventId = communitye1_.Id
       left outer join CommunityMembers communitym2_
         on participat0_.CommunityMemberId = communitym2*.Id
       left outer join Users user3_
         on communitym2_.UserId = user3_.Id
       inner join CommunityMembers communitym4_
         on participat0_.CommunityMemberId = communitym4_.Id
       inner join CommunityMembers communitym5_
         on participat0_.CommunityMemberId = communitym5_.Id
       inner join Communities community6_
         on communitym5_.CommunityId = community6_.Id
where  community6_.Id = 2002 /** @p0 **/
order  by participat0_.CreateDate asc

It generates left outer join and inner join, should be only one of them

Some additional links:

http://stackoverflow.com/questions/8152298/linq-to-nhibernate-duplicates-joins
http://stackoverflow.com/questions/10104949/nhibernate-generating-outer-join-for-a-fetch


Andrey Kozhyn added a comment — 12th April 2012, 14:14:57:

Here is a test case for this issue


Alexander Zaytsev added a comment — 12th April 2012, 15:58:09:

Could you please check with NH 3.3.0CR1?


Andrey Kozhyn added a comment — 13th April 2012, 6:53:00:

Same in 3.3.0CR1. Added a new test case for new version


Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions