title: hibernate - createCriteria or createAlias?
body: <p>If I want to search those students who take class "Math" and "John" is his group:</p>
  
  <p>shoud I use createCriteria or createAlias?</p>
  
  <pre><code>Criteria:
  
  Criteria criteria = session.createCriteria(Student.class);
  Criteria subquery1 = criteria.createCriteria("courses", course).add(Restrictions.eq(course.name, "Math"));
  Criteria subquery2 = criteria.createCriteria("group", student).add(Restrictions.eq(student.name, "John"));
  </code></pre>
  
  <p>how to put subquery1 and subquery2 together with initial criteria?</p>
  
  <pre><code>Alias:
  
  Criteria criteria = session.createCriteria(Student.class).
  createAlias("courses", course).add(Restrictions.eq(course.name, "Math")).
  createCriteria("group", student).add(Restrictions.eq(student.name, "John"));
  </code></pre>
  
  <p>When to use createCriteria and when createAlias? I think the boath are the same...</p>