title: Doctrine QueryBuilder getResult not returning nested array
body: <p>I have a join query in my "Item" entity repository class:</p>
  
  <pre><code>public function findByParentItem(parentItemCodes, excludedModules) {
      $qb = $this-&gt;getEntityManager()-&gt;createQueryBuilder();
  
      $qb-&gt;select('i', 'p')
          -&gt;from('Bundle:ItemParent', 'p')
          -&gt;join($this-&gt;getClassName(), 'i', Join::WITH, 'i.itemCode = p.itemCode')
          -&gt;where(
              $qb-&gt;expr()-&gt;andX(
                  $qb-&gt;expr()-&gt;in('p.parentItem', ':parentItem'),
                  $qb-&gt;expr()-&gt;notIn('i.moduleId', ':excludedModules')
              )
          )
          -&gt;setParameter('parentItem', $parentItemCodes)
          -&gt;setParameter('excludedModules', $excludedModules);
  
      return $qb-&gt;getQuery()-&gt;getResult();
  }
  </code></pre>
  
  <p>Item and ParentItem are not connected by association because it might point to another entity as well.</p>
  
  <p>I expect the result to be:</p>
  
  <pre><code>[
      0 =&gt; [
          0 =&gt; Item,
          1 =&gt; ParentItem
      ],
      1 =&gt; [
          0 =&gt; Item,
          1 =&gt; ParentItem
      ],
      ...
  ]
  </code></pre>
  
  <p>Instead I get:</p>
  
  <pre><code>[
      0 =&gt; Item,
      1 =&gt; ParentItem,
      2 =&gt; Item,
      3 =&gt; ParentItem,
      ...
  ]
  </code></pre>
  
  <p>Is this happening because there is no entity association?</p>
  
  <p><strong>EDIT</strong>: Changing <code>-&gt;from('Bundle:ParentItem', 'p', 'p.itemCode')</code> gives me:</p>
  
  <pre><code>[
      'ItemCode1' =&gt; ParentItem,
      0 =&gt; Item,
      'ItemCode2' =&gt; ParentItem,
      1 =&gt; Item,
      ...
  ]
  </code></pre>
  
  <p>If I do:</p>
  
  <pre><code>$qb-&gt;select('i', 'p.itemCode as itemCode')
  </code></pre>
  
  <p>I get this  which is more in the lines of what I want:</p>
  
  <pre><code>[
      0 =&gt; [
          0 =&gt; ParentItem,
          'itemCode' =&gt; 'ItemCode1'
      ],
      1 =&gt; [
          0 =&gt; ParentItem,
          'itemCode' =&gt; 'ItemCode2'
      ],
      ...
  ]
  </code></pre>
  
  <p><strong>EDIT:</strong> My entities:</p>
  
  <pre><code>/**
   * @ORM\Entity(repositoryClass="ItemRepository")
   * @ORM\Table(name="item")
   */
  class Item {
  
      /**
       * @ORM\Column(name="item_code", type="string", length=50)
       * @ORM\Id
       */
      protected $itemCode;
  
      /**
       * @ORM\Column(name="module_id", type="string", length=10, nullable=true)
       */
      protected $moduleId;
  
      // .. other properties
  }
  
  /**
   * @ORM\Entity(repositoryClass="ItemParentRepository")
   * @ORM\Table(name="item_parent")
   */
  class ItemParent {
      /**
       * @ORM\Column(name="item_code", type="string", length=50)
       * @ORM\Id
       */
      protected $itemCode;
  
      /**
       * @ORM\Column(name="parent_item", type="string", length=50)
       * @ORM\Id
       */
      protected $parentItem;
  }
  </code></pre>