title: Hibernate Criteria and row count restriction
body: <p>i have two entities named <strong>Parent</strong> and <strong>Child</strong>, linked in a <strong>one-to-many</strong> relationship. The Child entity has a boolean <code>isStudent</code> property. </p>
  
  <p>How do i get, using the Hibernate Criteria API, all the Parent entities that have at least one Child with <code>isStudent = true</code>?</p>
  
  <p>I was trying to use a Projection object to count all the parents that have at least one Child with the property correctly set, and then return those whose row count is greater than zero, like in the following piece of code (which doesn't work, though):</p>
  
  <pre><code>Criteria criteria = getCurrentSession().createCriteria(Parent.class);
  
  criteria.setProjection(Projections.alias(Projections.rowCount(), "count"))
  .add(Restrictions.gt("count", 0)).createCriteria("children")
  .add(Restrictions.eq("isStudent", true));
  </code></pre>
  
  <p>Thanks for your help</p>