title: Hibernate Criteria Query Join with Null Value
body: <p>I have a table called roles. Each role may belong to an organization. Roles that do not belong to an organization have a value of null. I want to find all the roles for a specific organization or where the organization is null within the table.</p>
  
  <pre><code>Criteria criteria = this.sessionFactory.getCurrentSession().createCriteria(Role.class)
  .add(Restrictions.or(
      Restrictions.eq("organization",organization.getId()), 
          Restrictions.isNull("organization")));
  </code></pre>
  
  <p>The Mapping file has:</p>
  
  <pre><code>&lt;many-to-one class="com.myname.models.Organization" name="organization"&gt;
  &lt;column name="organization_id" precision="22" scale="0" /&gt;
  &lt;/many-to-one&gt;
  </code></pre>
  
  <p>When the query runs, I get:</p>
  
  <pre><code>IllegalArgumentException occurred calling getter com.myname.models.Organization.id
  </code></pre>
  
  <p>I have found that if I modify the criteria to just query for nulls on organization everything works, however once I query for a value, I get the error.</p>
  
  <p>How to I modify the query or mapping file to meet my goals?</p>