title: How to return object from a DQL query?
body: <p>I have written a DQL query in Doctrine 2:</p>
  
  <pre><code>$qb-&gt;select('r.position')
      -&gt;from('\Entities\Races', 'r')
      -&gt;where($qb-&gt;expr()-&gt;eq('r.entrantId', ':entrant_id'))
      -&gt;setParameter('entrant_id', $this-&gt;entrantId);
  $query = $qb-&gt;getQuery();
  $aRaces = $query-&gt;getResult();
  </code></pre>
  
  <p>Currently it returns the results of the query in an array like so:</p>
  
  <pre><code>Array
  (
      [0] =&gt; Array
          (
              [position] =&gt; 10
          )
  
      [1] =&gt; Array
          (
              [position] =&gt; 4
          )
  )
  </code></pre>
  
  <p>I want the result to return an array of Races <strong>objects</strong> so that I can access the methods associated with the object (I'm pretty sure the previous version of Doctrine returned objects by default).</p>
  
  <p>I tried:</p>
  
  <pre><code>$aRaces = $query-&gt;getResult(Query::HYDRATE_OBJECT);
  </code></pre>
  
  <p>But that didn't make a difference.</p>
  
  <p>Appreciate the help</p>