mirror of
https://github.com/doctrine/orm.git
synced 2026-03-23 22:42:18 +01:00
DDC-812: DQL hydration of joined objects skipped when main instance already present in entity manager #999
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 (Sep 21, 2010).
Jira issue originally created by user dennis.verspuij:
I do the following:
the Books collection is not hydrated because the author instance was already
hydrated when populating $author1. This means when I call
count($author1->getBooks()) a third query is executed to fetch the Books again.
The result is even more problematic when adding a WITH clause to the
INNER JOIN, in that case one would expect the Books collection to only
contain the books matching matching that criteria.
The result is expected when commenting out the $author1 =... line, thus when
the author does not already exist in the entity manager.
I'm sorry I can't produce a test case right now.
@doctrinebot commented on GitHub (Sep 21, 2010):
Comment created by @beberlei:
fix formatting
@doctrinebot commented on GitHub (Oct 31, 2010):
Comment created by romanb:
Fixed in master. Note that your second case still "won't work" from your point of view. If the collection is already initialized it is not overridden. This is consistent with other behavior (what is in-memory is preserved). Fetch-joinining a collection and using WITH at the same time is not a nice thing to do since the meaning of the association is changed per-query. First $author->getBooks() means one thing (all books written by this author) and a few lines later something else (all books written by this author in the last 10 years or whatever). To get the desired result in your second case, that is, overriding the collection in-memory, set the REFRESH query hint. Note that this will change the meaning of Author#books though, as is always the case with fetch-join + WITH.
@doctrinebot commented on GitHub (Oct 31, 2010):
Issue was closed with resolution "Fixed"