-
Notifications
You must be signed in to change notification settings - Fork 934
NH-2016 - Fix joining to association twice using criteria #287
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
Conversation
Can you please enable Allow edits from maintainers PR option? |
Done |
Joining to association twice using criteria.
22ef4f7
to
6cf6fc8
Compare
Rebased, async code generated, and cleaned up. Especially I have made some renaming to improve code readability. The change does the job, but maybe it could be done in a simpler manner. @bahusoid, you are more used than me to the criteria code, may you have a look? |
Will be able to check code during next week. But it seems those changes might lead to unexpected behavior if query is mixed with Child child = null;
session.QueryOver<Obj>
.Fetch(o => o.Child).Eager
.Fetch(o => o.Child.SubChild).Eager
.JoinAlias(o => o.Child, () => child)
.Where(x => child.IsActive == true); It is my understanding the query above after this change will start to generate two joins to Child table. Am I right? Also after this change it seems query can contain multiple joins to fetch the same collection persister (with added multiple left join aliases for the same collection). I wonder how it will be handled. P.S. Actually the desired behavior is already possible via "Entity Join" - |
No I do not think so. And testing it, it does not, see the new commit.
I think this will somewhat "union" the fetches, with de-duplication in case of a |
Additional unexpected join was my main concern regarding this PR - if it's not a problem then it looks good to me. It can be useful. Regarding "Entity Join" changes - they seem unrelated to this PR. Am I wrong? And there is another catch - only one fetch mode ( |
True, but well, I do not think it would be worth it. This will be surely a bit complex for what looks to me as corner cases. (Fetching with a filter a collection while also projecting another part of it somehow? Maybe better load it fully and then process it in memory then.) |
I see no such places related to this PR. It seems this change was done only to remove the following line:
If you want to make such refactoring maybe it's better to do as another pr to better see actual changes for this PR. |
The cast is not there thanks to the change. Try compiling this line with an
It will fail. |
This line has not been removed. It has been changed to the correct call, required for robustly supporting the change since the That is in the "Fix compilation after rebase" commit. It was not compiling after the rebase, and this code had to change anyway. I have not checked that the change was also causing this place to potentially have an So this entity join change is not an unrelated refactoring, it is a legit change for this PR. |
Alias == Path is "Entity Join" specific. Which is not affected by this PR. This PR is about ability to create multiple aliases for the same association path. It makes no sense for "entity join" as there is no association path. You still can't create "entity join" where Alias != Path. But seeing those changes here made me think that "entity join" somehow affected. So I still think that all you need to do in this PR is add additional |
So just to be clear I think that |
I find this a bit overstated, but well, so be it. |
Joining to association twice using criteria.
I'm added criteria alias for unique identification join statement. This makes it possible to declare complex expressions join.
Deviations in the standard behavior of the rest of the functionality I hadn't noticed
Jira issue NH-3472 (dup of NH-2016, #990).
Fixes #990