boolean applyDefaultSorting = (defaultSortingProperty != null);
final List<Criterion> fields = query.getCriteria();
if (fields != null) {
for (final Criterion criterion : fields) {
final CriteriaContext context = new CriteriaContext();
context.setCriterion(criterion);
context.setOrderingCriteria(criteria);
if (criterion.getValue() != null || criterion.getSortingType() != SortingType.NONE || criterion.getComparator() == ComparatorType.IS_NULL || criterion.getComparator() == ComparatorType.IS_NOT_NULL) {
CriteriaDecorator criteriaDecorator = criteriaDecoratorByPojoPropertyKey.get(criterion.getPojoProperty());
if (criteriaDecorator == null) {
criteriaDecorator = new DefaultCriteriaDecorator();
}
criteriaDecorator.render(context);
}
if (applyDefaultSorting && criterion.getSortingType() != SortingType.NONE && criterion.getPojoProperty().equals(defaultSortingProperty)) {
applyDefaultSorting = false;
}
}
}
// sort forced on the default property
if (applyDefaultSorting) {
final Criterion field = new Criterion(defaultSortingProperty);
field.setSortingType(sortingType);
final CriteriaContext context = new CriteriaContext();
context.setCriterion(field);
context.setOrderingCriteria(criteria);
sortCriteriaDecorator.render(context);
}
// handle scrolling when too many data
if (!QueryMode.FULL_RESULT.equals(query.getQueryMode())) {