title: Doctrine batch processing query while iterate
body: <p>In symfony4 i'm using the iteration solution as explained in <a href="https://www.doctrine-project.org/projects/doctrine-orm/en/2.6/reference/batch-processing.html#iterating-large-results-for-data-processing" rel="nofollow noreferrer">doctrine documentation</a></p>
  
  <p>The problem is that i need to perform a query inside the foreach cicle and if i do, the iteration ends.</p>
  
  <pre class="lang-php prettyprint-override"><code>    //...
      $repo = this-&gt;_em-&gt;getRepository('App\Entity\EmailAddressStatus');
      // Gets 15k results
      $q = $this-&gt;_em-&gt;createQuery('select u from App\Entity\User u');
      $iterableResult = $q-&gt;iterate();
  
      foreach ($iterableResult as $row) {
  
          $emails = $row[0]-&gt;getEmails();
          foreach($emails as $email){
              // If i do this the iteration ends after first result
              $check = $repo-&gt;isEmailBlackListed($email);
              // Do something with $check and $email...
          }
          // detach from Doctrine, so that it can be Garbage-Collected immediately
          $this-&gt;_em-&gt;detach($row[0]);
      }
  </code></pre>