Jira issue originally created by user austinsmorris:
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 accountcontacts table with a 3-way composite PK of the contact_id, account_id, and typeid.
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.
Comment created by @beberlei:
[~austinsmorris] 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.
Comment created by austinsmorris:
Sorry, I don't have the original select clause. I ended up doing something different and can't seem to find my original code.
I have another person that reported a simliiar bug with reproducable test case. I hope to investigate this very soon.