}
}
}
if (hasOrder) {
Collections.sort(results, new OrderComparator(query.getOrdering()));
// trim results to max length if necessary
int max = query.maxResults();
if (max >= 0 && (results.size() > max)) {
results.subList(max, results.size()).clear();