title: Symfony Doctrine Hydrator - With custom hydrator I lose my ManyToOne relation
body: <p>I would like to extends ObjectHydrator to benefit of the hydration of my ManyToOne relation and add extra field to the Entity.</p>
  
  <p>Here is my hydrator: StatisticsDataHydrator.php</p>
  
  <pre><code>namespace AppBundle\Hydrator\ProjectAssignment;
  
  use AppBundle\Entity\ProjectAssignment;
  use Doctrine\ORM\Internal\Hydration\ObjectHydrator;
  
      class StatisticsDataHydrator extends ObjectHydrator
      {
          /**
           * {@inheritdoc}
           */
          protected function hydrateRowData(array $data, array &amp;$result)
          {
              $hydrated_result = array();
              parent::hydrateRowData($data, $hydrated_result);
  
              /** @var ProjectAssignment $project_assignment */
              $project_assignment = $hydrated_result[0][0];
  
              $result[] = $project_assignment;
          }
      }
  </code></pre>
  
  <p>Here is my config: config.yml</p>
  
  <pre><code>doctrine:
      orm:
          hydrators:
              project_assignment_statisticsdata_hydrator: AppBundle\Hydrator\ProjectAssignment\StatisticsDataHydrator
  </code></pre>
  
  <p>Where I don't use the hydrator I have no problem:</p>
  
  <pre><code>/**
   * @param ProjectStage $stage
   * @return array
   */
  public function findByStageWithStatisticsData(ProjectStage $stage){
      $qb = $this-&gt;createQueryBuilder('pa');
  
      $qb
          //-&gt;addSelect('44')
          -&gt;where($qb-&gt;expr()-&gt;eq('pa.project_stage', ':stage'))
          -&gt;setParameter('stage', $stage);
  
      return $qb-&gt;getQuery()-&gt;getResult();
  }
  </code></pre>
  
  <p><a href="https://i.stack.imgur.com/XnbYM.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/XnbYM.png" alt="enter image description here"></a></p>
  
  <p>But when I use my hydrator:</p>
  
  <pre><code>/**
   * @param ProjectStage $stage
   * @return array
   */
  public function findByStageWithStatisticsData(ProjectStage $stage){
      $qb = $this-&gt;createQueryBuilder('pa');
  
      $qb
          -&gt;addSelect('1234') // referencial value
          -&gt;where($qb-&gt;expr()-&gt;eq('pa.project_stage', ':stage'))
          -&gt;setParameter('stage', $stage);
  
      return $qb-&gt;getQuery()-&gt;getResult('project_assignment_statisticsdata_hydrator');
  }
  </code></pre>
  
  <p><a href="https://i.stack.imgur.com/xBc1k.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/xBc1k.png" alt="enter image description here"></a></p>
  
  <p>The strangest behavior is that the same occure with this config: config.yml</p>
  
  <pre><code>doctrine:
      orm:
          hydrators:
              project_assignment_statisticsdata_hydrator: Doctrine\ORM\Internal\Hydration\ObjectHydrator
  </code></pre>
  
  <p>I have tried all kind of fetch on relation with no success:</p>
  
  <pre><code>@ORM\ManyToOne(... , fetch="EAGER")
  @ORM\ManyToOne(... , fetch="LAZY")
  ...
  </code></pre>
  
  <p>Maybe I have to use a Proxy on my Entity, I really don't know :(</p>
  
  <p>Thank you for any help!</p>