mirror of
https://github.com/doctrine/orm.git
synced 2026-03-24 06:52:09 +01:00
DDC-2530: Fetch eager in onetomany is not storing the collection resulting in same query being executed twice #3175
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 @doctrinebot on GitHub (Jun 25, 2013).
Originally assigned to: @beberlei on GitHub.
Jira issue originally created by user legolas:
I have two entities Users and Bugs (A user can report multiple bugs) sharing bidirectional onetomany relation between them. On the inverse side of the relation I have put fetch = eager as given below.
Now when I run this code:
Firstly user entity is fetched from the user table with id = 7. Then it looks for the bugs associated with user_id = 7 in the bugs table. This seems to be the expected behavior where due to the eager fetch the related associations are automatically loaded. What seems to be the bug is, after this when the user's reported bugs are called, an unnecessary query is executed which again looks for the bugs in the bugs table related to the user_id = 7 and that is basically the same query as before. This is just a redundant query. So the eager fetch should have stored the associated bugs in the first call itself and the subsequent call to the reported bugs should just return the already fetched entities.
@doctrinebot commented on GitHub (Jun 25, 2013):
Comment created by @ocramius:
[~legolas] are you actually using 2.0 or is this on a newer branch? (2.3?)
@doctrinebot commented on GitHub (Jun 25, 2013):
Comment created by legolas:
Yup my bad, it is 2.3.3 version of doctrine. Atleast this is what i am seeing in the doctrine ORM version.php.
@doctrinebot commented on GitHub (Jun 25, 2013):
Comment created by @beberlei:
verified
@doctrinebot commented on GitHub (Jun 25, 2013):
Comment created by @beberlei:
Fixed and scheduled for 2.3.4
@doctrinebot commented on GitHub (Jun 25, 2013):
Issue was closed with resolution "Fixed"
@doctrinebot commented on GitHub (Jun 25, 2013):
Comment created by legolas:
Thanx