Doctrine 2 - ORM
  1. Doctrine 2 - ORM
  2. DDC-2697

ObjectHydrator::hydrateRowData fails to hydrate first fetch joined entity

    Details

    • Type: Bug Bug
    • Status: Open
    • Priority: Major Major
    • Resolution: Unresolved
    • Affects Version/s: 2.3, 2.4
    • Fix Version/s: None
    • Component/s: ORM
    • Security Level: All
    • Labels:
    • Environment:
      All

      Description

      Let's say I have accounts, contacts, and contact types. Any given contact can have be any kind of contact type to any account. This is all managed through an account_contacts table with a 3-way composite PK of the contact_id, account_id, and type_id.

      All of this translates to 4 entities, the account, contact, type, and accountContact entity. The id of the accountContact entity is the three other entities which is holds.

      When I use query builder to retrieve the accountContacts based on some condition, and also fetch join contacts, accounts, and types so that they are eagerly loaded, the ObjectHydrator fails to load the first accountContact returned.

      This is because the first time through hydrateRowData, the fetch joined entities are hydrated first. The problem is $this->_rsm->parentAliasMap[$dqlAlias] does not contain an entry for the accountContact (root entity). Not until an accountContact is hydrated does that get set. In the mean time, the other three entities were set to null because there is no parent alias yet (in version 2.4, this is line 405.

      Subsequent loops through hydrateRowData work because by this time the parent alias is set. But that first row returned is always an accountContact containing three null objects.

        Activity

        Austin Morris created issue -
        Hide
        Benjamin Eberlei added a comment -

        Austin Morris Can you show the QueryBuilder select clause you are using? Have you tried sorting the accountContacts first?

        $qb->select('accountContacts, contact, account, type')
        

        This way it should definately work, and then there is also some attempts to resort this way if you dont have that, but its not always working.

        Show
        Benjamin Eberlei added a comment - Austin Morris Can you show the QueryBuilder select clause you are using? Have you tried sorting the accountContacts first? $qb->select('accountContacts, contact, account, type') This way it should definately work, and then there is also some attempts to resort this way if you dont have that, but its not always working.
        Hide
        Austin Morris added a comment -

        Sorry, I don't have the original select clause. I ended up doing something different and can't seem to find my original code.

        Show
        Austin Morris added a comment - Sorry, I don't have the original select clause. I ended up doing something different and can't seem to find my original code.
        Hide
        Benjamin Eberlei added a comment -

        I have another person that reported a simliiar bug with reproducable test case. I hope to investigate this very soon.

        Show
        Benjamin Eberlei added a comment - I have another person that reported a simliiar bug with reproducable test case. I hope to investigate this very soon.

        This list may be incomplete, as errors occurred whilst retrieving source from linked applications:

        • Request to http://www.doctrine-project.org/fisheye/ failed: Error in remote call to 'FishEye 0 (http://www.doctrine-project.org/fisheye/)' (http://www.doctrine-project.org/fisheye) [AbstractRestCommand{path='/rest-service-fe/search-v1/crossRepositoryQuery', params={query=DDC-2697, expand=changesets[0:20].revisions[0:29],reviews}, methodType=GET}] : Received status code 503 (Service Temporarily Unavailable)

          People

          • Assignee:
            Benjamin Eberlei
            Reporter:
            Austin Morris
          • Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

            • Created:
              Updated: