title: How do I write a criteria to exclude some entities
body: <p>I want to write a hibernate criteria that excludes certain entities. Here's what I have so far: </p>
  
  <pre><code>Criterion exclusion1 = Restrictions.not(Restrictions.conjunction()
      .add(Restrictions.eq("color", "blue");
      .add(Restrictions.eq("type", "aaa"))
      .add(Restrictions.eq("subtype1", "bbb"))
      .add(Restrictions.eq("subtype2", "ccc"));
  
  Criteria crit = session.createCriteria(MyObject.class);
  crit.add(exclusion1);
  
  List result = crit.list();
  </code></pre>
  
  <p>There are several such exclusion criterion. This seems to do what I want except that if any of the fields are null I want it to be included. e.g an entity with color = blue, type = aaa, subtype1 and subtype2 are null to be included.</p>
  
  <p>How can I rewrite this to <strong>not</strong> exclude that entity?</p>