SortField sortField = new SortField("age", SortField.Type.INT);
Sort sort = new Sort(sortField);
cacheQuery.sort(sort);
for (int i = 0; i < 2; i ++) {
ResultIterator iterator = cacheQuery.iterator(new FetchOptions().fetchMode(FetchOptions.FetchMode.LAZY));
try {
assert cacheQuery.getResultSize() == 4 : cacheQuery.getResultSize();
int previousAge = 0;
while (iterator.hasNext()) {
Person person = (Person) iterator.next();
assert person.getAge() > previousAge;
previousAge = person.getAge();
}
}
finally {
iterator.close();
}
}
StaticTestingErrorHandler.assertAllGood(cacheAMachine1, cacheAMachine2);
}