title: Hibernate Criteria order by term length
body: <p>I want to order my terms by lenght,which is equivalent to:</p>
  
  <pre><code>SELECT term FROM &lt;table_name&gt; where term  like '%now%' order by length(term ) asc;
  </code></pre>
  
  <p>in hibernate.</p>
  
  <p>For the moment this is my criteria code:</p>
  
  <pre><code>    Criteria criteria = session.createCriteria(myClass.class);
      criteria.setProjection(Projections.distinct(Projections.property("term")));
      criteria.add(Restrictions.ilike("term", "%xyz%"));
      criteria.addOrder(Order.asc("term"));
      criteria.setMaxResults(10);
      List&lt;String&gt; list = criteria.list();
  </code></pre>
  
  <p>Cheers</p>