BATCH-1860: Use sub query for Derby for JdbcPagingItemReader
Order the results before the ROW_NUM restriction is applied (and make related infrastructure tests more robust)
This commit is contained in:
@@ -57,7 +57,7 @@ public class IbatisPagingItemReaderAsyncTests {
|
||||
public void init() {
|
||||
SimpleJdbcTemplate jdbcTemplate = new SimpleJdbcTemplate(dataSource);
|
||||
maxId = jdbcTemplate.queryForInt("SELECT MAX(ID) from T_FOOS");
|
||||
for (int i = maxId + 1; i <= ITEM_COUNT; i++) {
|
||||
for (int i = ITEM_COUNT; i > maxId; i--) {
|
||||
jdbcTemplate.update("INSERT into T_FOOS (ID,NAME,VALUE) values (?, ?, ?)", i, "foo" + i, i);
|
||||
}
|
||||
assertEquals(ITEM_COUNT, SimpleJdbcTestUtils.countRowsInTable(jdbcTemplate, "T_FOOS"));
|
||||
|
||||
@@ -63,7 +63,7 @@ public class JdbcPagingItemReaderAsyncTests {
|
||||
public void init() {
|
||||
SimpleJdbcTemplate jdbcTemplate = new SimpleJdbcTemplate(dataSource);
|
||||
maxId = jdbcTemplate.queryForInt("SELECT MAX(ID) from T_FOOS");
|
||||
for (int i = maxId + 1; i <= ITEM_COUNT; i++) {
|
||||
for (int i = ITEM_COUNT; i > maxId; i--) {
|
||||
jdbcTemplate.update("INSERT into T_FOOS (ID,NAME,VALUE) values (?, ?, ?)", i, "foo" + i, i);
|
||||
}
|
||||
assertEquals(ITEM_COUNT, SimpleJdbcTestUtils.countRowsInTable(jdbcTemplate, "T_FOOS"));
|
||||
@@ -141,7 +141,7 @@ public class JdbcPagingItemReaderAsyncTests {
|
||||
factory.setDataSource(dataSource);
|
||||
factory.setSelectClause("select ID, NAME, VALUE");
|
||||
factory.setFromClause("from T_FOOS");
|
||||
factory.setSortKey("ID");
|
||||
factory.setSortKey("VALUE");
|
||||
reader.setQueryProvider((PagingQueryProvider) factory.getObject());
|
||||
reader.setRowMapper(new ParameterizedRowMapper<Foo>() {
|
||||
public Foo mapRow(ResultSet rs, int i) throws SQLException {
|
||||
|
||||
@@ -63,7 +63,7 @@ public class JdbcPagingQueryIntegrationTests {
|
||||
public void init() {
|
||||
jdbcTemplate = new SimpleJdbcTemplate(dataSource);
|
||||
maxId = jdbcTemplate.queryForInt("SELECT MAX(ID) from T_FOOS");
|
||||
for (int i = maxId + 1; i <= itemCount; i++) {
|
||||
for (int i = itemCount; i > maxId; i--) {
|
||||
jdbcTemplate.update("INSERT into T_FOOS (ID,NAME,VALUE) values (?, ?, ?)", i, "foo" + i, i);
|
||||
}
|
||||
assertEquals(itemCount, SimpleJdbcTestUtils.countRowsInTable(jdbcTemplate, "T_FOOS"));
|
||||
|
||||
@@ -70,7 +70,7 @@ public class JdbcPagingRestartIntegrationTests {
|
||||
public void init() {
|
||||
jdbcTemplate = new SimpleJdbcTemplate(dataSource);
|
||||
maxId = jdbcTemplate.queryForInt("SELECT MAX(ID) from T_FOOS");
|
||||
for (int i = maxId + 1; i <= itemCount; i++) {
|
||||
for (int i = itemCount; i > maxId; i--) {
|
||||
jdbcTemplate.update("INSERT into T_FOOS (ID,NAME,VALUE) values (?, ?, ?)", i, "foo" + i, i);
|
||||
}
|
||||
assertEquals(itemCount, SimpleJdbcTestUtils.countRowsInTable(jdbcTemplate, "T_FOOS"));
|
||||
@@ -147,7 +147,7 @@ public class JdbcPagingRestartIntegrationTests {
|
||||
factory.setDataSource(dataSource);
|
||||
factory.setSelectClause("select ID, NAME, VALUE");
|
||||
factory.setFromClause("from T_FOOS");
|
||||
factory.setSortKey("ID");
|
||||
factory.setSortKey("VALUE");
|
||||
reader.setQueryProvider((PagingQueryProvider) factory.getObject());
|
||||
reader.setRowMapper(new ParameterizedRowMapper<Foo>() {
|
||||
public Foo mapRow(ResultSet rs, int i) throws SQLException {
|
||||
|
||||
@@ -60,7 +60,7 @@ public class JpaPagingItemReaderAsyncTests {
|
||||
public void init() {
|
||||
SimpleJdbcTemplate jdbcTemplate = new SimpleJdbcTemplate(dataSource);
|
||||
maxId = jdbcTemplate.queryForInt("SELECT MAX(ID) from T_FOOS");
|
||||
for (int i = maxId + 1; i <= ITEM_COUNT; i++) {
|
||||
for (int i = ITEM_COUNT; i > maxId; i--) {
|
||||
jdbcTemplate.update("INSERT into T_FOOS (ID,NAME,VALUE) values (?, ?, ?)", i, "foo" + i, i);
|
||||
}
|
||||
assertEquals(ITEM_COUNT, SimpleJdbcTestUtils.countRowsInTable(jdbcTemplate, "T_FOOS"));
|
||||
|
||||
@@ -12,3 +12,4 @@ log4j.category.org.springframework.jdbc.datasource=INFO
|
||||
# log4j.category.org.springframework.batch=DEBUG
|
||||
log4j.category.org.springframework.batch.support=INFO
|
||||
# log4j.category.org.springframework.retry=DEBUG
|
||||
# log4j.category.org.springframework.batch.item.database=DEBUG
|
||||
|
||||
@@ -9,11 +9,11 @@ CREATE TABLE T_FOOS (
|
||||
|
||||
ALTER TABLE T_FOOS ADD PRIMARY KEY (ID);
|
||||
|
||||
INSERT INTO t_foos (id, name, value) VALUES (1, 'bar1', 1);
|
||||
INSERT INTO t_foos (id, name, value) VALUES (2, 'bar2', 2);
|
||||
INSERT INTO t_foos (id, name, value) VALUES (3, 'bar3', 3);
|
||||
INSERT INTO t_foos (id, name, value) VALUES (4, 'bar4', 4);
|
||||
INSERT INTO t_foos (id, name, value) VALUES (5, 'bar5', 5);
|
||||
INSERT INTO t_foos (id, name, value) VALUES (1, 'bar2', 2);
|
||||
INSERT INTO t_foos (id, name, value) VALUES (2, 'bar4', 4);
|
||||
INSERT INTO t_foos (id, name, value) VALUES (3, 'bar1', 1);
|
||||
INSERT INTO t_foos (id, name, value) VALUES (4, 'bar5', 5);
|
||||
INSERT INTO t_foos (id, name, value) VALUES (5, 'bar3', 3);
|
||||
|
||||
CREATE TABLE T_WRITE_FOOS (
|
||||
ID BIGINT NOT NULL,
|
||||
|
||||
@@ -9,11 +9,11 @@ CREATE TABLE T_FOOS (
|
||||
|
||||
ALTER TABLE T_FOOS ADD PRIMARY KEY (ID);
|
||||
|
||||
INSERT INTO t_foos (id, name, value) VALUES (1, 'bar1', 1);
|
||||
INSERT INTO t_foos (id, name, value) VALUES (2, 'bar2', 2);
|
||||
INSERT INTO t_foos (id, name, value) VALUES (3, 'bar3', 3);
|
||||
INSERT INTO t_foos (id, name, value) VALUES (4, 'bar4', 4);
|
||||
INSERT INTO t_foos (id, name, value) VALUES (5, 'bar5', 5);
|
||||
INSERT INTO t_foos (id, name, value) VALUES (1, 'bar2', 2);
|
||||
INSERT INTO t_foos (id, name, value) VALUES (2, 'bar4', 4);
|
||||
INSERT INTO t_foos (id, name, value) VALUES (3, 'bar1', 1);
|
||||
INSERT INTO t_foos (id, name, value) VALUES (4, 'bar5', 5);
|
||||
INSERT INTO t_foos (id, name, value) VALUES (5, 'bar3', 3);
|
||||
|
||||
CREATE TABLE T_WRITE_FOOS (
|
||||
ID BIGINT NOT NULL,
|
||||
|
||||
@@ -9,11 +9,11 @@ CREATE TABLE T_FOOS (
|
||||
|
||||
ALTER TABLE T_FOOS ADD PRIMARY KEY (ID);
|
||||
|
||||
INSERT INTO t_foos (id, name, VALUE) VALUES (1, 'bar1', 1);
|
||||
INSERT INTO t_foos (id, name, VALUE) VALUES (2, 'bar2', 2);
|
||||
INSERT INTO t_foos (id, name, VALUE) VALUES (3, 'bar3', 3);
|
||||
INSERT INTO t_foos (id, name, VALUE) VALUES (4, 'bar4', 4);
|
||||
INSERT INTO t_foos (id, name, VALUE) VALUES (5, 'bar5', 5);
|
||||
INSERT INTO t_foos (id, name, value) VALUES (1, 'bar2', 2);
|
||||
INSERT INTO t_foos (id, name, value) VALUES (2, 'bar4', 4);
|
||||
INSERT INTO t_foos (id, name, value) VALUES (3, 'bar1', 1);
|
||||
INSERT INTO t_foos (id, name, value) VALUES (4, 'bar5', 5);
|
||||
INSERT INTO t_foos (id, name, value) VALUES (5, 'bar3', 3);
|
||||
|
||||
CREATE TABLE T_WRITE_FOOS (
|
||||
ID BIGINT NOT NULL,
|
||||
|
||||
Reference in New Issue
Block a user