Sorry to come in the middle of a very interesting conversation (this new jdbc reader can be really interesting)
I'm glad we fixed the issue.
We found a bug in 1.0.0-FINAL JdbcCursorItemReader (sorry !).
It happens on second or subsequent restarts.
This is because bufferredReader don't remember the previous processedRowCount.
bufferredReader#processedRowCount only contains the rows processed on the current restart.
When update is called, JdbcCursorItemReader stores in the execution context the rows during this restart. It should store the rows processed during this restart AND the previous ones.
This issue can be resolved changing the JdbcCursorItemReader#open code - see //CHANGE, //END CHANGE block at the end (note : a new constructor BufferredResultSetReader(ResultSet,RowMapper,long processedRowCount) would have been better than setting the field directly) :
Code:
public void open(ExecutionContext context) {
Assert.state(!initialized, "Stream is already initialized. Close before re-opening.");
Assert.isNull(rs);
Assert.notNull(context, "ExecutionContext must not be null");
executeQuery();
initialized = true;
long currentProcessedRow = 0;
if (context.containsKey(getKey(CURRENT_PROCESSED_ROW))) {
try {
currentProcessedRow = context.getLong(getKey(CURRENT_PROCESSED_ROW));
while(rs.next()){
if(rs.getRow() == currentProcessedRow){
break;
}
}
} catch (SQLException se) {
throw getExceptionTranslator().translate("Attempted to move ResultSet to last committed row", sql, se);
}
}
//CHANGE
bufferredReader = new BufferredResultSetReader(rs, mapper);
bufferredReader.processedRowCount = currentProcessedRow;
//END CHANGE
}