title: Criteria API Conditionally Evaluate 'NULL'
body: <p>I have the following Criteria API query used to evaluate a given value against a number of <code>Subject</code> attributes.</p>
  
  <pre><code>...
      Expression literal = builder.literal((String) "%" + filterValue + "%");
  
      // When the globalFilter is deleted it returns ""
      if (!"".equals(filterValue)) {
          // JPQL equivilant: SELECT e FROM Subject e JOIN e.company c JOIN e.contact ct WHERE c.name LIKE :literal OR ct.firstName LIKE :literal ... etc
          List&lt;Predicate&gt; globalPredicate = new ArrayList&lt;&gt;();
  
          globalPredicate.add(builder.like(subject.get(Subject_.email), literal));
          globalPredicate.add(builder.like(subject.join(Subject_.contact).get(Contact_.firstName), literal));
          globalPredicate.add(builder.like(subject.join(Subject_.contact).get(Contact_.lastName), literal));
          globalPredicate.add(builder.like(subject.join(Subject_.metier).get(Metier_.name), literal));
          globalPredicate.add(builder.like(subject.join(Subject_.company).get(Company_.name), literal));
  
          predicates.add(builder.or(globalPredicate.toArray(new Predicate[globalPredicate.size()])));
      }
  ...
  </code></pre>
  
  <p>This creates the following query:</p>
  
  <pre><code>SELECT t1.UID AS a1, t1.EMAIL AS a2, t1.PASSWORD AS a3, t1.VERSION AS a4, t1.COMPANY_ID AS a5, t1.METIER_ID AS a6, t1.ACCOUNT_ID AS a7, t1.CONTACT_ID AS a8 FROM METIER t3, COMPANY t2, SUBJECT t1, CONTACT t0 WHERE (((((t1.EMAIL LIKE ? OR t0.FIRSTNAME LIKE ?) OR t0.LASTNAME LIKE ?) OR t3.NAME LIKE ?) OR (t2.NAME LIKE ? IS NOT NULL)) AND (((t0.ID = t1.CONTACT_ID) AND (t3.ID = t1.METIER_ID)) AND (t2.ID = t1.COMPANY_ID))) LIMIT ?, ?
  </code></pre>
  
  <p>The problem I am having is that the <code>Subject_.company</code> can be <code>null</code>. The query effectively ignores ALL the entries that have <code>Subject_.company</code> set to <code>null</code>. </p>
  
  <p>I need to somehow modify this query so that the <code>null</code> values are not automatically discarded.</p>