title: select objects by joining relationships with doctrine DQL
body: <p>I have three entities: <code>Project</code>, <code>RequestMatcher</code>, and <code>Response</code>. Here is how they are related:</p>
  
  <pre><code>$project-&gt;getRequestMatchers(); // Project has many RequestMatchers
  
  $requestMatcher-&gt;getActiveResponse(); // RequestMatcher has one active Response
  </code></pre>
  
  <p>How can i write DQL to get all active <code>Response</code>s for a <code>Project</code>? </p>
  
  <pre><code>    $query = $this-&gt;getEntityManager()-&gt;createQuery(
          "SELECT resp FROM $responseClass resp
                 JOIN $requestMatcherClass req WITH req.project = :project
                 WHERE resp.id IN(req.active_response_id)"
      );
  
      $query-&gt;setParameter('project', $project);
  </code></pre>
  
  <p>I'm getting the following exception though: </p>
  
  <pre><code>[Doctrine\ORM\Query\QueryException]                                 
    [Syntax Error] line 0, col 230: Error: Expected Literal, got 'req'
  </code></pre>
  
  <p>I've also tried this with the same result:</p>
  
  <pre><code>    $query = $this-&gt;getEntityManager()-&gt;createQuery(
          "SELECT resp FROM $responseClass resp
                 LEFT JOIN resp.requestMatcher req WITH req.project = :project
                 WHERE resp IN(req.activeResponse)"
      );
  </code></pre>
  
  <p>This is the sql that will give me the id's</p>
  
  <pre><code>select active_response_id from (
    select active_response_id from request_matchers where project_id = 1
  ) t
  </code></pre>