Doctrine2StepHydration, relation collection not hydrated if empty #9997
Unanswered
megusta420
asked this question in
Support Questions
Replies: 1 comment
-
Well, it looks like using leftJoin instead of innerJoin is the way to go. But please correct me if there is a better way to do this. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I'm trying to implement this thing: https://ocramius.github.io/blog/doctrine-orm-optimization-hydration
So, for instance, I have a User entity and User ManyToMany Initiatives. This way any User can participate in any Initiative.
All goes well when there are some Initiatives User already joined.
But the problem arises when the User didn't join any of the Initiatives, so the User's MtM Initiatives collection should be empty, so the Initiatives collection stays uninitialized when there are no query results.
The question is: how to initialize all user collections even when there are no query results?
Sample code:
So when we have nested relation collections NOT initialized, this later leads to N+1 lazy loading queries in my case when I access these not initialized collections, which I want to also avoid.
Beta Was this translation helpful? Give feedback.
All reactions