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

Use table group joins for many-to-many in Criteria and Entity loaders #2687

Merged

Conversation

bahusoid
Copy link
Member

@bahusoid bahusoid commented Feb 23, 2021

Cons: query is executed for each not found element for not filtered collection for Criteria (so not ideal when not-found="ignore"). But it's the same behavior for LINQ and lazy loading. I will try to address it in separate PR (hibernate uses inner join for many-to-many lazy loading so basically always ignores not found records)

Pros: Removes some hacks (like BasicCollectionPersister.ManyToManySelectFragment) and unifies behavior between LINQ, Criteria and entity loaders.

Possible breaking change: Default not-found behavior now works correctly so now it throws ObjectNotFoundException exception on many-to-many Criteria fetch for not found records.

@bahusoid bahusoid force-pushed the manyToManyCriteriaTableGroupJoin branch from b6c53fa to bc7e5c3 Compare March 16, 2023 15:29
@bahusoid bahusoid changed the title WIP Use table group joins for many-to-many in Criteria and Entity loaders Use table group joins for many-to-many in Criteria and Entity loaders Mar 16, 2023
@bahusoid bahusoid marked this pull request as ready for review March 16, 2023 15:51
@fredericDelaporte fredericDelaporte added this to the 5.5 milestone Jul 27, 2023
Copy link
Member

@fredericDelaporte fredericDelaporte left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When testing with the new tests but without NHibernate changes, only the queryover test in NH750 fails. All other tests succeeds, included the lazy loading one. Your description seems to imply the "lazy load with throws for not found" test should have failed without your change.

Could you rebase this branch? It appears to be based on a quite old master dating back to the the start of the year.

@bahusoid bahusoid force-pushed the manyToManyCriteriaTableGroupJoin branch from 69d1442 to a0a4dd2 Compare July 31, 2023 08:52
@bahusoid bahusoid force-pushed the manyToManyCriteriaTableGroupJoin branch from 733e8e2 to 0bafa66 Compare July 31, 2023 09:10
@bahusoid
Copy link
Member Author

only the queryover test in NH750 fails.

Good catch. Indeed, lazy loading is not affected by this bug as GetSelectFragment overload with rhsAlias is not used there (

.SetSelectClause(collectionPersister.GetSelectFragment(alias, CollectionSuffixes[0]).ToSqlStringFragment(false)
)

I updated description.

@bahusoid bahusoid force-pushed the manyToManyCriteriaTableGroupJoin branch from 438175b to a59b6d0 Compare July 31, 2023 10:50
@bahusoid bahusoid merged commit 4949174 into nhibernate:master Aug 1, 2023
10 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants