private static void addOrder(PersistentEntity entity,
                                 CriteriaQuery query,
                                 From queryRoot,
                                 CriteriaBuilder criteriaBuilder,
                                 String sort, String order, boolean ignoreCase) {
        if (sort.equalsIgnoreCase(entity.getIdentity().getName())) {
            Expression path = queryRoot;

            if (ignoreCase) {
                path = criteriaBuilder.upper(path);
            }
            if (DynamicFinder.ORDER_DESC.equals(order)) {
                query.orderBy(criteriaBuilder.desc(path));
            } else {
                query.orderBy(criteriaBuilder.asc(path));
            }
        } else {
            Expression path = queryRoot.get(sort);

            if (ignoreCase) {
                path = criteriaBuilder.upper(path);
            }
            if (DynamicFinder.ORDER_DESC.equals(order)) {
                query.orderBy(criteriaBuilder.desc(path));
            } else {
                query.orderBy(criteriaBuilder.asc(path));
            }
        }
    }
private static void addOrder ( PersistentEntity entity , CriteriaQuery query , From queryRoot , CriteriaBuilder criteriaBuilder , String sort , String order , boolean ignoreCase ) { if ( sort . equalsIgnoreCase ( entity . getIdentity ( ) . getName ( ) ) ) { Expression path = queryRoot ; if ( ignoreCase ) { path = criteriaBuilder . upper ( path ) ; } if ( DynamicFinder . ORDER_DESC . equals ( order ) ) { query . orderBy ( criteriaBuilder . desc ( path ) ) ; } else { query . orderBy ( criteriaBuilder . asc ( path ) ) ; } } else { Expression path = queryRoot . get ( sort ) ; if ( ignoreCase ) { path = criteriaBuilder . upper ( path ) ; } if ( DynamicFinder . ORDER_DESC . equals ( order ) ) { query . orderBy ( criteriaBuilder . desc ( path ) ) ; } else { query . orderBy ( criteriaBuilder . asc ( path ) ) ; } } }
Add order directly to criteria.