title: How to get if children exists
body: <p>I have two Entity:</p>
  
  <pre><code>/**
   * @ORM\Entity
   * @ORM\Table(name="main")
   */
  class Main
  {
      /**
       * @ORM\Id
       * @ORM\Column(type="integer")
       * @ORM\GeneratedValue(strategy="AUTO")
       */
      protected $id;
      /**
       * @ORM\ManyToMany(targetEntity="Sub", mappedBy="mains")
       * @ORM\OrderBy({"position" = "ASC"})
       */
      protected $subs;
  
      /**
       * @ORM\Column(type="string", length=255)
       */
      protected $name;
  }
  
  /**
   * @ORM\Entity
   * @ORM\Table(name="sub")
   */
  class Sub
  {
      /**
       * @ORM\Id
       * @ORM\Column(type="integer")
       * @ORM\GeneratedValue(strategy="AUTO")
       */
      protected $id;
  
      /**
      * @var \Doctrine\Common\Collections\ArrayCollection
      *
      * @ORM\ManyToMany(targetEntity="Main", inversedBy="subs")
      * @ORM\JoinTable(name="sub_main",
      *   joinColumns={
      *     @ORM\JoinColumn(name="sub_id", referencedColumnName="id")
      *   },
      *   inverseJoinColumns={
      *     @ORM\JoinColumn(name="main_id", referencedColumnName="id")
      *   }
      * )
      */
      protected $mains; 
  
      /**
       * @ORM\Column(type="string", length=255)
       */
      protected $name;
  }
  </code></pre>
  
  <p>It works good. In controller I would like to get all Mains objects which have childrens (Sub).</p>
  
  <pre><code>$em = $this-&gt;getDoctrine()-&gt;getManager();
  $queryBuilder = $em-&gt;createQueryBuilder();
  
  $qb-&gt;select('m, s')
              -&gt;from('AppBundle:Main', 'm')
              -&gt;where('ONLY MAINS WITH CHILDRENS (SUB)')
              -&gt;leftJoin('m.subs', 's')
                  ;
  
          $mains = $qb-&gt;getQuery()-&gt;getResult();
  </code></pre>
  
  <p>So what condition should be in where clause?</p>
  
  <p>I found that in simply SQL I can use subqueries or operator exists, but how can I use it in Doctrine in Symfony 2?</p>