Skip to content


DDC-1652: ArrayHydrator with composite primary key #2295

doctrinebot opened this Issue · 6 comments

2 participants


Jira issue originally created by user ghennady:


Problem with ArrayHydrator and composite primary key.

Given the following data (PRIMARY KEY (ancestor*id,descendant*id))

$query = $em->createQuery("SELECT c,d FROM ResourceClosure c JOIN c.descendant d WHERE c.ancestor = 1");

echo 'ObjectHydrator result count = '.count($query->getResult()).PHP_EOL;
echo 'ArrayHydrator result count = '.count($query->getArrayResult()).PHP_EOL;
ObjectHydrator result count = 2 
ArrayHydrator result count = 1 

Expected both counts are equals 2.
In case getArrayResult() in result only first record hydrated, second record are ommited

Below examples model and insertion in db

 * @Entity
class ResourceClosure
     * @Id
     * @ManyToOne(targetEntity="Resource")
     * @JoinColumn(name="ancestor_id", referencedColumnName="id")
    private $ancestor;

     * @Id
     * @ManyToOne(targetEntity="Resource")
     * @JoinColumn(name="descendant_id", referencedColumnName="id")
     * @var Resource
    private $descendant;

     * @Column(name="depth", type="integer")
     * @var integer
    private $depth;
$resource1 = new Entity\Resource('resource1');

$resource2 = new Entity\Resource('resource2');


$closure1 = new Entity\ResourceClosure();


$closure2= new Entity\ResourceClosure();



Its work like expected in case entity ResourceClosure has simple primary key.


Comment created by @beberlei:



Comment created by @beberlei:

@Guilherme - This is because the SQL Walker decides to $addMetaColumns => false here. Why did we add this? This skips all meta columns in Array Results, i don't get what that is good for.


Comment created by @beberlei:

PR: #290

Guilherme has to verify this


Comment created by @guilhermeblanco:

Resolved with merge of #290


Issue was closed with resolution "Fixed"


Comment created by @beberlei:

Merged back to 2.2, will be in 2.2.1

@beberlei beberlei was assigned by doctrinebot
@doctrinebot doctrinebot added this to the 2.2.1 milestone
@doctrinebot doctrinebot closed this
@doctrinebot doctrinebot added the Bug label
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.