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-2769 - Linq Fetch over component has no effect on generated SQL #1232

Closed
nhibernate-bot opened this issue Oct 12, 2017 · 4 comments
Closed

Comments

@nhibernate-bot
Copy link
Collaborator

cremor created an issue — 16th June 2011, 1:53:04:

NH-2615 fixed the exceptions that occured when a Linq query with a fetch on a component was executed but the fetch has still no effect on the generated SQL.

Attached is a patch that modifies the already existing test (NHSpecificTest\NH2705) so it also checks the generated statement.


David Roth added a comment — 10th May 2012, 11:32:17:

Is there any chance for fixing this issue soon? Anyone working on it or planning to do so?
We are using a lot of components in our project and we can`t fetch references with LINQ on collections because of this issue.


Oskar Berggren added a comment — 18th January 2013, 8:34:09:

David Roth has made a test case available at:
https://github.com/davrot/nhibernate-core/tree/NH3373


David Roth added a comment — 15th February 2013, 13:01:45:

New github location for the testcase: https://github.com/davidroth/nhibernate-core/tree/NH3373


ahmed zeyada added a comment — 24th December 2015, 20:57:25:

is there any workaround for this problem ? the only way i can see is fetching it through lazy loading which is not good solution

@hazzik
Copy link
Member

hazzik commented Jul 27, 2018

Now the generated hql expression is equivalent to

select c from Company c 
join fetch c.Address a
join fetch a.Country 

But it should be:

select c from Company c join fetch c.Address.Country

In other words the Linq translator has to detect that c.Address is mapped as a component and should not add a join fetch for it, but instead for c.Address.Company.

@bahusoid
Copy link
Member

bahusoid commented Sep 2, 2020

@maca88 Isn't this issue already fixed by #1922?

@maca88
Copy link
Contributor

maca88 commented Sep 2, 2020

Yes this is fixed and tested by:

person = s.Query<Person>().Fetch(o => o.Address).ThenFetch(o => o.Continent).FirstOrDefault(o => o.Id == 1);

@davidd4
Copy link

davidd4 commented Oct 21, 2020

Fetch over dynamic component has no effect.
Is this the supposed behavior?
Is there a workaround for it?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants