title: Query builder join on ManyToMany relationship
body: <p>I am trying to use query builder to select all the categories that belong to a certain <code>superCategory</code> (<code>category</code> and <code>superCategory</code> have a many to many relationship).</p>
  
  <p>However, I am unable to build a correct query builder sentence because I don't know how to reference to the <code>superCategory</code> from my <code>category</code>as there is no <code>superCategory</code> field inside my category ID.</p>
  
  <p>The objects in the database look like :</p>
  
  <pre><code>Category:
    id
    name
  
  SuperCategory
    id
    name
  
  categories_superCategories
    id
    category_id
    superCategory_id
  </code></pre>
  
  <p>Here are the definition of my objects (yml files):</p>
  
  <pre><code>YOP\YourOwnPoetBundle\Entity\TraitCategory:
    type: entity
    repositoryClass: YOP\YourOwnPoetBundle\Repository\TraitCategoryRepository
    table: null
    fields:
      id:
        type: integer
        id: true
        generator:
          strategy: AUTO
      name:
        type: string
        length: '255'
    lifecycleCallbacks: {  }
    manyToMany:
      superCategories:
        targetEntity: SuperCategory
        joinTable:
          name: traitCategories_superCategories
          joinColumns:
            traitCategory_id:
              referencedColumnName: id
          inverseJoinColumns:
            superCategory_id:
              referencedColumnName: id
  </code></pre>
  
  <p>and</p>
  
  <pre><code>YOP\YourOwnPoetBundle\Entity\SuperCategory:
    type: entity
    repositoryClass: YOP\YourOwnPoetBundle\Repository\SuperCategoryRepository
    table: null
    fields:
      id:
        type: integer
        id: true
        generator:
          strategy: AUTO
      name:
        type: string
        length: '255'
    lifecycleCallbacks: {  }
    manyToMany:
      msgCategories:
        targetEntity: MsgCategory
        mappedBy: superCategories
      traitCategories:
        targetEntity: TraitCategory
        mappedBy: superCategories
  </code></pre>
  
  <p>How would I build a query builder sentence to get the categories that belong to a certain <code>superCategory</code>?</p>
  
  <p>The query inside my <code>CategoryRepository</code>:</p>
  
  <pre><code>$this-&gt;createQueryBuilder('c')
              -&gt;innerJoin( ?????? )
              -&gt;setParameter('superCategoryName', $superCategoryName);
  </code></pre>