title: HQL Query to check if size of collection is 0 or empty
body: <p>I try to generate a HQL query that include user with a empty appoinment collections(mapped by OneToMany):</p>
  
  <pre><code>SELECT u FROM User u JOIN u.appointments uas WHERE u.status = 1 AND (uas.time.end &lt; :date OR size(uas) = 0)
  </code></pre>
  
  <p>I tries it on several manners (<code>NOT EXIST ELEMENT(), IS NULL</code>)
  also see: <a href="https://stackoverflow.com/questions/1105011/how-to-check-if-the-collection-is-empty-in-nhibernate-hql/1105057#1105057">How to check if the collection is empty in NHibernate (HQL)?</a> (This doesn't work for me)</p>
  
  <p>but still not the result I want to see or some error in HQL or SQL SERVER</p>
  
  <p><strong>Note:</strong></p>
  
  <p>the query without the JOIN works:</p>
  
  <pre><code>"FROM User u WHERE u.status = 1 AND size(u.appointments) = 0"
  </code></pre>
  
  <p><strong>Solved</strong></p>
  
  <p>Another JOIN solved the problem:</p>
  
  <pre><code>SELECT u FROM User u LEFT JOIN u.appointments pas1 LEFT JOIN pas1.slot t WHERE u.status = 1 AND t.end &lt;= :date1 OR t.end IS NULL ORDER BY u.name asc
  </code></pre>