title: Hibernate Criteria API: get n random rows
body: <p>I can't figure out how to fetch n random rows from a criteria instance:</p>
  
  <pre><code>Criteria criteria = session.createCriteria(Table.class);
  criteria.add(Restrictions.eq('fieldVariable', anyValue));
  ...
  </code></pre>
  
  <p>Then what? I can't find any doc with Criteria API </p>
  
  <p>Does it mean I should use HQL instead?</p>
  
  <p>Thanx!</p>
  
  <p>EDIT: I get the number of rows by:</p>
  
  <pre><code>int max = criteria.setProjecxtion(Projections.rowCount()).uniqueResult();
  </code></pre>
  
  <p>How do I fetch n random rows with indexes between 0 and max?
  Thx again!</p>