int pagesToRead = Math.min(3, total/pageSize);
if (count >= pagesToRead*pageSize) {
count -= pagesToRead*pageSize;
}
ExecutionContext executionContext = new ExecutionContext();
executionContext.putInt("JdbcPagingItemReader.read.count", count);
// Assume the primary keys are in order
List<Map<String, Object>> ids = jdbcTemplate
.queryForList("SELECT ID,NAME FROM T_FOOS ORDER BY ID ASC");
logger.debug("Ids: "+ids);
int startAfterValue = (new Long(ids.get(count - 1).get("ID").toString())).intValue();
logger.debug("Start after: " + startAfterValue);
Map<String, Object> startAfterValues = new LinkedHashMap<String, Object>();
startAfterValues.put("ID", startAfterValue);
executionContext.put("JdbcPagingItemReader.start.after", startAfterValues);
((ItemStream) reader).open(executionContext);
for (int i = count; i < total; i++) {
Foo item = reader.read();
logger.debug("Item: " + item);