mirror of
https://github.com/doctrine/orm.git
synced 2026-03-24 06:52:09 +01:00
x-to-one and fetch behaviour bug? #5274
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @jmirandase on GitHub (Sep 26, 2016).
Hi,
I have the following entities
and when I call:
The following queries are executed:
I was expecting a single query for this method, however 2 additional queries are executed. And the reason for that is here
I was wondering why is that? Why an inverse side of a x-to-one can never be lazy?. I actually don't need to fetch the data from Recording and MeetingSchedule entities. I think those additional queries are totally unnecessary and a waste or resources. Is there something that I am missing here? Is this the expected behaviour? Have I made a mistake with my annotations even though I don't think this is the case because these are one-to-one associations and the owning side are Recording and MeetingSchedule respectively.
@coudenysj commented on GitHub (Sep 27, 2016):
Do the associations need to be bidirectional? I think that should solve the extra queries (if you don't access the properties straight away).
@jmirandase commented on GitHub (Sep 28, 2016):
@coudenysj thanks for your suggestion. I think I can get rid of the bidirectional association between MeetingEvent and Recording, but unfortunately it's not possible for Meeting and MeetingSchedule. So if I can't avoid bidirectional associations, it seems that I will end up with extra queries during hydration, is that right?. I haven't tested yet, but this could be really bad for many-to-one associations :(
@coudenysj commented on GitHub (Sep 28, 2016):
The comment was changed from "Inverse side can never be lazy" to "Inverse side of x-to-one can never be lazy" in
fe7ef4bbeb (diff-6e8c1c1e78b054ba05e20ea09d877865R1798), but it only applies to OneToOne relations.@theredled commented on GitHub (Jan 11, 2018):
I have the same problem, it has a huge impact on performance.
And thus some questions: