title: Hibernate CriteriaQuery check for null join
body: <p>I am converting to hibernate 5.2.4 and to use CriteriaQuery.  Have a slight issue in testing for a null join on a file.  This is what I was doing before which worked.</p>
  
  <pre><code>@Entity
  public class MyClass {
   ....
   @ManyToOne(..)
   public MyDetail getMyDetail() { 
    return myDetail;  
   }
  }
  
  Criteria criteria = session.createCriteria(MyClass.class);
  criteria.createAlias("myDetail", "md");
  criteria.add(Restrictions.isNotNull("myDetail"));
  </code></pre>
  
  <p>I have been checking like this and sometimes it does not work:</p>
  
  <pre><code>andPredicate = builder.and(andPredicate, builder.isNotNull(
                      root.get(MyClass_.myDetail)));
  </code></pre>
  
  <p>Is there a correct way to do this?  I have tried to create the join and test for a null but this also does not work:</p>
  
  <pre><code>Join&lt;MyClass, MyDetail&gt; myJoin = root.join(MyClass_.myDetail);
  
  andPredicate = builder.and(andPredicate, myJoin.isNotNull());
  </code></pre>
  
  <p>Thanks.</p>