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

Add support fetch=EAGER OneToOne and ManyToOne for inheritance #11855

Open
wants to merge 3 commits into
base: 3.3.x
Choose a base branch
from

Conversation

zavodnoyapl1992
Copy link

@zavodnoyapl1992 zavodnoyapl1992 commented Mar 1, 2025

Resolve N+1 problem when declare fetch="EAGER" and use inheritance in ManyToOne and OneToOne relations

resolve #11599

@zavodnoyapl1992
Copy link
Author

if this approach is OK for you I'll add functional tests for this

if ($eagerEntity->inheritanceType !== ClassMetadata::INHERITANCE_TYPE_NONE) {
continue; // now this is why you shouldn't use inheritance
if ($eagerEntity->rootEntityName === $eagerEntity->name || $assoc['isOwningSide']) {
Copy link
Member

Choose a reason for hiding this comment

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

This is not enough to check if its only the root entity, it could be part of a deeper hierachy where from Root Entity A, the current entity B still has subclasses C and D.

Copy link
Author

Choose a reason for hiding this comment

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

good point, fixed + added tests

Copy link
Author

Choose a reason for hiding this comment

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

Hey @beberlei what do you think about this improvement? it's affected only inheritance with single table, mapped by final class and OneToOne or ManyToOne relation, let me know if you prefer to see additional tests or something else

Ps, I really want these improvement, because inheritance is a powerful feature, but when I try to display grid with 100 items I have additional 100 queries..

@zavodnoyapl1992 zavodnoyapl1992 force-pushed the support-eager-and-inheritance branch from 4a6b342 to 0abc438 Compare March 2, 2025 10:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

setFetchMode does not respect second level association
2 participants