title: When is a Doctrine collection effectively hydrated?
body: <p>In Doctrine Documentation about <a href="http://doctrine-orm.readthedocs.org/en/latest/reference/working-with-associations.html#filtering-collections" rel="nofollow">filtering associations</a>, there's the following code example:</p>
  
  <pre><code>use Doctrine\Common\Collections\Criteria;
  
  $group          = $entityManager-&gt;find('Group', $groupId);
  $userCollection = $group-&gt;getUsers();
  
  $criteria = Criteria::create()
      -&gt;where(Criteria::expr()-&gt;eq("birthday", "1982-02-17"))
      -&gt;orderBy(array("username" =&gt; Criteria::ASC))
      -&gt;setFirstResult(0)
      -&gt;setMaxResults(20)
  ;
  
  $birthdayUsers = $userCollection-&gt;matching($criteria);
  </code></pre>
  
  <p>This code is supposed to illustrate the following sentence: </p>
  
  <blockquote>
    <p>If the collection has not been loaded from the database yet, the filtering API can work on the SQL level to make optimized access to large collections.</p>
  </blockquote>
  
  <p>But isn't the collection loaded at the <code>$group-&gt;getUsers()</code> call? So how can it not be hydrated when the criteria matching is performed?</p>