RESOLVED BATCH-737: JdbcCursorItemReader will spin through entire resultset if numberOfProcessRows=0

This commit is contained in:
dsyer
2008-07-21 08:27:40 +00:00
parent 83aa1f6fb2
commit e338f24233
2 changed files with 31 additions and 4 deletions

View File

@@ -259,11 +259,8 @@ public class JdbcCursorItemReader<T> extends AbstractBufferedItemReaderItemStrea
private void moveCursorToRow(int row) {
try {
int count = 0;
while (rs.next()) {
while (row!=count && rs.next()) {
count++;
if (count == row) {
break;
}
}
}
catch (SQLException se) {

View File

@@ -196,6 +196,36 @@ public abstract class AbstractDataSourceItemReaderIntegrationTests extends
assertEquals(foo3, reader.read());
}
/**
* Rollback scenario with restart - input source rollbacks to last
* commit point.
* @throws Exception
*/
public void testRollbackOnFirstChunkAndRestart() throws Exception {
getAsItemStream(reader).open(executionContext);
Foo foo1 = (Foo) reader.read();
Foo foo2 = (Foo) reader.read();
Assert.state(!foo2.equals(foo1));
Foo foo3 = (Foo) reader.read();
Assert.state(!foo2.equals(foo3));
rollback();
getAsItemStream(reader).update(executionContext);
// create new input source
reader = createItemReader();
getAsItemStream(reader).open(executionContext);
assertEquals(foo1, reader.read());
assertEquals(foo2, reader.read());
}
public void testMultipleRestarts() throws Exception {
getAsItemStream(reader).open(executionContext);