q.setOrdering("name ascending");
q.setRange(0, 5);
Collection c = (Collection) q.execute();
ArrayList foundNames = new ArrayList();
for (Iterator it = c.iterator(); it.hasNext();) {
User u = (User) it.next();
foundNames.add(u.getName());
}
q.closeAll();
pm.currentTransaction().commit();
pm.evictAll();
assertEquals("not expected result", expectedNames.subList(0, 5), foundNames);
pm.currentTransaction().begin();
q = pm.newQuery(User.class);
q.setOrdering("name ascending");
q.setRange(2, 5);
c = (Collection) q.execute();
foundNames.clear();
for (Iterator it = c.iterator(); it.hasNext();) {
User u = (User) it.next();
foundNames.add(u.getName());
}
q.closeAll();
pm.currentTransaction().commit();
pm.evictAll();
assertEquals("not expected result", expectedNames.subList(2, 5), foundNames);
pm.currentTransaction().begin();
q = pm.newQuery(User.class);
q.setOrdering("name ascending");
c = (Collection) q.execute();
foundNames.clear();
for (Iterator it = c.iterator(); it.hasNext();) {
User u = (User) it.next();
foundNames.add(u.getName());
}
q.closeAll();
pm.currentTransaction().commit();
pm.evictAll();
assertEquals("not expected result", expectedNames, foundNames);