//Build command to read all customers
Command custCommand = Command.FACTORY.createCommand("select * from CUSTOMER order by ID");
custCommand.setConnection(getConnection());
//Create a pager with the command
Pager pager = new PagerImpl(custCommand, 2);
//Get and work with first page
DataObject root = pager.next();
DataObject customer1 = root.getDataObject("CUSTOMER[1]");
DataObject customer2 = root.getDataObject("CUSTOMER[2]");
assertEquals(1, customer1.getInt("ID"));
assertEquals(2, customer2.getInt("ID"));
//Get and work with the second page
root = pager.next();
customer1 = root.getDataObject("CUSTOMER[1]");
customer2 = root.getDataObject("CUSTOMER[2]");
assertEquals(3, customer1.getInt("ID"));
assertEquals(4, customer2.getInt("ID"));
// First page again
root = pager.previous();
customer1 = root.getDataObject("CUSTOMER[1]");
customer2 = root.getDataObject("CUSTOMER[2]");
assertEquals(1, customer1.getInt("ID"));
assertEquals(2, customer2.getInt("ID"));