Remove dynamically an ordering to the result set in org.hibernate.Criteria
问题 I have a Criteria with: Criteria criteria= session.createCriteria(Libro.class).addOrder( Order.asc("ID") ); However, when I want to get the rowcount fail: criteria.setProjection(Projections.rowCount()); because there is an order by in the query. How to remove dynamically the ordering in the Criteria? I mean, I am looking for like criteria.removeOrder("ID") . 回答1: Most Criteria are actually instances of CriteriaImpl. If you cast your Criteria to CriteriaImpl and get the iterator for orders,