title: Doctrine 2 WHERE IN clause using a collection of entities
body: <p>I'm attempting to build a query in Doctrine 2 that finds all <code>Vacancy</code> entities which are related to any of the given <code>VacancyWorkingHours</code> entities.</p>
  
  <p>The <code>Vacancy</code> entity looks as follows:</p>
  
  <pre><code>/**
   * Vacancy
   *
   * @ORM\Table(name="vacancy")
   * @ORM\Entity(repositoryClass="JaikDean\CareersBundle\Entity\VacancyRepository")
   */
  class Vacancy
  {
      /**
       * @var integer
       *
       * @ORM\Column(name="id", type="integer")
       * @ORM\Id
       * @ORM\GeneratedValue(strategy="AUTO")
       */
      private $id;
  
      /**
       * @var VacancyWorkingHours
       *
       * @ORM\ManyToOne(targetEntity="VacancyWorkingHours", inversedBy="vacancies")
       * @ORM\JoinColumn(name="vacancy_working_hours_id", referencedColumnName="id")
       **/
      private $workingHours;
  
      /* Other fields and methods are inconsequential */
  }
  </code></pre>
  
  <p>My query currently looks as follows, but returns no results because of the where clause. In this example, <code>$workingHours</code> is a <code>Doctrine\Common\Collections\ArrayCollection</code> instance containing a number of <code>VacancyWorkingHours</code> entities</p>
  
  <pre><code>$q = $this-&gt;createQueryBuilder('v')
      -&gt;select('v')
      -&gt;andWhere('v.workingHours IN (:workingHours)')
      -&gt;setParameter('workingHours', $workingHours-&gt;toArray());
  ;
  </code></pre>