title: Symfony2 - Custom Repository + Doctrine QueryBuilder = Errors?
body: <p>I have written a custom query in a repository:</p>
  
  <pre><code>public function findProductDetails($filter = array(), $offset = 0, $limit = 0)
  {   
      $query = $this-&gt;getEntityManager()
              -&gt;createQuery('SELECT prod, comp, cat FROM PaulDemoBundle:Product prod JOIN prod.category cat JOIN prod.company comp WHERE prod.productName LIKE \'%'.$filter['freetext'].'%\' ');
      $query-&gt;setFirstResult($offset);
      $query-&gt;setMaxResults($limit);
  
      return $query-&gt;getResult();
  }
  </code></pre>
  
  <p>Now I am trying to add an ORDER BY into it, using the orderBy() part of the Doctrine Query Builder:</p>
  
  <pre><code>$query-&gt;orderBy('prod.productRef', 'ASC');
  </code></pre>
  
  <p>But I get errors when trying to run this:</p>
  
  <pre><code>Call to undefined method Doctrine\ORM\Query::orderBy()
  </code></pre>
  
  <p>So I added the following to the top of my repository, underneath the USE call for EntityRepository:</p>
  
  <pre><code>use Doctrine\ORM\Query;
  </code></pre>
  
  <p>But, no dice.</p>
  
  <p>All documentation I have found simply shows the query being built using the $query->orderBy() method. No where in the Symfony2 documentation does it say how to set up your repo to work with the Doctrine Query Builder.</p>
  
  <p>How on earth do I add the orderBy() method?</p>
  
  <p>Am I even constructing my query properly? (Its based on the Symfony2 docs, but they are pretty poor tbh)</p>