title: Querying Join Table in Doctrine
body: <p>I have the following two classes which are have a <em>ManyToMany</em> relationship and saved in a joining table called <code>countries_involved</code>.</p>
  
  <pre><code>class CountriesInvolved
  {
  /**
   * @var integer
   */
  private $id;
  
  /**
   * @var string
   */
  private $description;
  
  /**
   * @var \DateTime
   */
  private $createdAt;
  
  /**
   * @var \DateTime
   */
  private $updatedAt;
  
  /**
   * @var \ACME\SouthBundle\Entity\Country
   */
  private $country;
  
  /**
   * @var \Doctrine\Common\Collections\Collection
   */
  private $involvement;
  }
  </code></pre>
  
  <p>and </p>
  
  <pre><code>class Involvement
  {
  /**
   * @var integer
   */
  private $id;
  
  /**
   * @var string
   */
  private $name;
  
  /**
   * @var string
   */
  private $description;
  }
  </code></pre>
  
  <p>The relationship is defined as below in YML</p>
  
  <pre><code>manyToMany:
      involvement:
          targetEntity:   Involvement
          joinTable:
              name: countries_involvement
              joinColumns:
                  case_country_involved_id:
                      referencedColumnName:   id
              inverseJoinColumns:
                  involvement_id:
                      referencedColumnName:   id
  </code></pre>
  
  <p>I'm trying to return results of countries involved based on the id of an involvement but kind of stuck in writing the query without getting an error. Here's what I tried thus far:</p>
  
  <pre><code>$em = $this-&gt;getDoctrine()-&gt;getManager()-&gt;createQueryBuilder();
      $q = $em-&gt;select('c')
      -&gt;from('ACMESouthBundle:CountriesInvolved','c')
      -&gt;innerJOIN('c.Involvement','i')
      -&gt;where('i.id = 1') 
      -&gt;groupBy('c.country')-&gt;getQuery();
  </code></pre>
  
  <p>The error is:</p>
  
  <pre><code>[Semantical Error] line 0, col 80 near 'i WHERE i.id': Error: Class ACME\SouthBundle\Entity\CountriesInvolved has no association named Involvement
  </code></pre>