title: Unable to use size function in HQL
body: <pre class="lang-java prettyprint-override"><code>List&lt;Object&gt; outputList = session.createQuery(
     &quot;select usr from User usr where size(usr.user_messages) &gt; 2 &quot;
  ).list();
  </code></pre>
  <p>When I run the above query I get the below exception. The DB used is Postgres. How can I use <code>size</code> in the HQL?</p>
  <pre class="lang-java prettyprint-override"><code>@OneToMany(mappedBy  = &quot;user&quot;, cascade = CascadeType.PERSIST)
  private Set&lt;UserMessages&gt; user_messages = new HashSet&lt;UserMessages&gt;();
  </code></pre>
  <pre><code>Exception in thread &quot;main&quot; java.lang.ClassCastException: org.hibernate.query.sqm.tree.expression.SqmCollectionSize cannot be cast to org.hibernate.sql.ast.tree.expression.Expression
      at org.hibernate.query.sqm.sql.BaseSqmToSqlAstConverter.visitComparisonPredicate(BaseSqmToSqlAstConverter.java:2271)
      at org.hibernate.query.sqm.sql.BaseSqmToSqlAstConverter.visitComparisonPredicate(BaseSqmToSqlAstConverter.java:205)
      at org.hibernate.query.sqm.tree.predicate.SqmComparisonPredicate.accept(SqmComparisonPredicate.java:67)
      at org.hibernate.query.sqm.sql.BaseSqmToSqlAstConverter.visitQuerySpec(BaseSqmToSqlAstConverter.java:423)
      at org.hibernate.query.sqm.sql.internal.StandardSqmSelectTranslator.visitSelectStatement(StandardSqmSelectTranslator.java:185)
      at org.hibernate.query.sqm.sql.internal.StandardSqmSelectTranslator.translate(StandardSqmSelectTranslator.java:127)
      at org.hibernate.query.sqm.internal.ConcreteSqmSelectQueryPlan.buildCacheableSqmInterpretation(ConcreteSqmSelectQueryPlan.java:226)
      at org.hibernate.query.sqm.internal.ConcreteSqmSelectQueryPlan.resolveCacheableSqmInterpretation(ConcreteSqmSelectQueryPlan.java:193)
      at org.hibernate.query.sqm.internal.ConcreteSqmSelectQueryPlan.performList(ConcreteSqmSelectQueryPlan.java:153)
      at org.hibernate.query.sqm.internal.QuerySqmImpl.doList(QuerySqmImpl.java:437)
      at org.hibernate.query.spi.AbstractQuery.list(AbstractQuery.java:1356)
          at com.learning.hibernate.HibernateMain.main(HibernateMain.java:103)
  </code></pre>