Usages of

org.hibernate.internal.CriteriaImpl.OrderEntry.getOrder()
@Override @Transactional(readOnly = true) public long countByCriteria(DetachedCriteria dc) { CriteriaImpl impl = ReflectionUtils.<CriteriaImpl> getFieldValue(dc, "impl"); Iterator<OrderEntry> it = impl.iterateOrderings(); List<OrderEntry> orderEntries = null; boolean notEmpty = it.hasNext(); if (notEmpty) { // remove order orderEntries = new ArrayList<OrderEntry>(); while (it.hasNext()) { orderEntries.add(it.next()); it.remove(); } } Criteria c = dc.getExecutableCriteria(sessionFactory .getCurrentSession()); c.setProjection(Projections.projectionList() .add(Projections.rowCount())); long count = (Long) c.uniqueResult(); if (notEmpty) { // restore order for (OrderEntry oe : orderEntries) impl.addOrder(oe.getOrder()); } dc.setProjection(null); dc.setResultTransformer(CriteriaSpecification.ROOT_ENTITY); return count; }
@Override @Transactional(readOnly = true) public long countByCriteria(DetachedCriteria dc) { CriteriaImpl impl; try { impl = (CriteriaImpl) CRITERIA_IMPL_GETTER.invokeExact(dc); } catch (Throwable e) { throw new RuntimeException(e.getMessage(), e); } ResultTransformer rt = impl.getResultTransformer(); Iterator<OrderEntry> it = impl.iterateOrderings(); List<OrderEntry> orderEntries = null; boolean notEmpty = it.hasNext(); if (notEmpty) { // remove order orderEntries = new ArrayList<>(); while (it.hasNext()) { orderEntries.add(it.next()); it.remove(); } } Criteria c = dc.getExecutableCriteria(sessionFactory.getCurrentSession()); c.setProjection(Projections.projectionList().add(Projections.rowCount())); long count = (Long) c.uniqueResult(); if (notEmpty) { // restore order for (OrderEntry oe : orderEntries) impl.addOrder(oe.getOrder()); } dc.setProjection(null); dc.setResultTransformer(rt); return count; }
Usage snippet has been bookmarked! Review your bookmarks
Thank you! Review your likes