title: How to join two different criterias under Hibernate?
body: <p>I have three tables in my database, a Student, a Classe, and an Assignement. The POJOs are as the following:</p>
  
  <pre><code>Student{
      Classe currentClasse;
      Set&lt;Assignement&gt; assignements;
  }
  
  Classe{
      Set&lt;Assignement&gt; assignements;
      SchoolYear schoolYear;
  }
  
  Assignement{
      Classe classe;
      Student student;
      Boolean pass;
  }
  </code></pre>
  
  <p>Basically, a student has a current class, and a list of assignements (all the classes he's been assigned to).</p>
  
  <p>My problem is that under hibernate, I'd like to know all the students who do not have a classe (<code>is null</code>) <strong>OR</strong> who are assigned to a class belonging to the schoolyear "1" but have <code>pass</code> set to <code>true</code></p>
  
  <p>I managed to make two separate criterias to get what I want:</p>
  
  <pre><code>session.createCriteria(Student.class)
         .add(Restrictions.isNull("classeActuelle"))
  </code></pre>
  
  <p>and</p>
  
  <pre><code>session.createCriteria(Student.class)
         .createAlias("assignements", "a")
         .add(Restrictions.eq("a.pass", Boolean.TRUE)
         .createAlias("a.classe","c")
         .add(Restrictions.eq("c.schoolYear", "1"))
  </code></pre>
  
  <p>but I don't know how I can "unite" those two criterias with an or... </p>