Details
Description
ObjectHydrator has bug in hydrate entities with relation to entity of this same class throught reference entity. Example Model:
EntityA
- id
- title (string)
- entitiesB (annotation: @ORM\OneToMany(targetEntity="EntityB", mappedBy="entityAFrom"))
EntityB
- id
- entityAFrom (annotation: @ORM\ManyToOne(targetEntity="EntityA", inversedBy="entitiesB"))
- entityATo (annotation: @ORM\ManyToOne(targetEntity="EntityA"))
- type (string)
Scenario:
Execution of dql query 'SELECT a, b, ba FROM EntityA AS a LEFT JOIN a.entitiesB AS b LEFT JOIN b.entityATo AS ba' with max results set to "1" and data in database:
EntityATable:
id | title
1 | a
2 | b
EntityBTable:
id | entityAFromId | entityAToId | type
1 | 1 | 2 | type
Resume:
I expected collection of EntityA object (size=1 becouse I set max results to 1) with hydrated entitiesB collection (size=1 becouse in db is only 1 record) and hydrated entityTo object. entitiesB property of entityTo object should be empty PersistCollection (ready to lazy load) but is null...
I can provide TestCase for this issue.
Attached a working testcase.
Please put it into tests/Doctrine/Tests/ORM/Functional/Ticket and run:
Please make that test fail from your perspective, i think it reproduces your test-case exactly.