title: How can I restrict certain entities from my queryBuilder?
body: <p>I'm trying to use a queryBuilder to get some users who did NOT have an appointment with subject 'PC' (&quot;Prise de Contact&quot;).
  and fit certain criteria of appointment dates ina related entity, &quot;Amont&quot;.</p>
  <p>I'm reusing a queryBuilder using &quot;clone&quot; so I can perform my search on the result of the queryBuilder that was made for displaying the page.
  I'm trying to use the notIn() method from the expressions of queryBuilder</p>
  <pre><code>    $nots
      -&gt;leftJoin('u.rendezVouses', 'rdv')
      -&gt;andWhere(&quot;rdv.objetRDV = 'PC'&quot;);
  
      $qb
      -&gt;select('u.id')
      -&gt;leftJoin('u.amonts', 'a')
      -&gt;andWhere($qb-&gt;expr()-&gt;notIn('u.id', $nots))
      -&gt;andWhere('a.datePremierRDV &lt;= :dateNj')
      -&gt;andWhere('a.datePremierRDV &gt;= :dateMini')
      -&gt;andWhere($qb-&gt;expr()-&gt;isNotNull('a.datePremierRDV'))
      -&gt;setParameter('dateNj', $dateNj)
      -&gt;setParameter('dateMini', $dateMini);
  
      $array = $qb-&gt;getQuery()-&gt;getResult();
  </code></pre>
  <p>here's the error message I get in symfony profiler:</p>
  <blockquote>
  <p>Error: Method Doctrine\Common\Collections\ArrayCollection::__toString() must not throw an exception, caught ErrorException: Catchable Fatal Error: Object of class Doctrine\ORM\EntityManager could not be converted to string</p>
  </blockquote>