Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
nhibernate-bot opened this issue Oct 12, 2017 · 0 comments · Fixed by #2496
Closed

Comments

@nhibernate-bot
Copy link
Collaborator

nhibernate-bot commented Oct 12, 2017

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


@hazzik hazzik added this to the next minor milestone Sep 8, 2020
hazzik pushed a commit that referenced this issue Sep 8, 2020
@hazzik hazzik changed the title NH-3115 - Duplicate joins when using fetching with where in LINQ query NH-3115 - Should de-duplicate joins when using fetching with where in LINQ query Sep 8, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
3 participants