public static Criteria applyInlineCount(Criteria crit)
{
crit.setMaxResults(0);
crit.setFirstResult(0);
CriteriaImpl impl = (CriteriaImpl) crit;
Iterator<OrderEntry> iter = impl.iterateOrderings();
while (iter.hasNext()) {
iter.next();
iter.remove();
}
crit.setProjection( Projections.rowCount());