BATCH-335 and BATCH-316: As part of the documentation efforts of RC1, the DrivingQueryItemReader has had javadoc updates. Specifically, the MultipleColumnJdbcKeyGenerator, which has been a source of confusion, has had it's javadocs beefed up.
The KeyGenerator interface was also renamed to KeyCollector. The issue was raised that it's not actually generating keys, but rather collecting them from the database.
This commit is contained in:
@@ -32,7 +32,7 @@ public class DrivingQueryItemReaderTests extends TestCase {
|
||||
private DrivingQueryItemReader createItemReader() throws Exception{
|
||||
|
||||
DrivingQueryItemReader inputSource = new DrivingQueryItemReader();
|
||||
inputSource.setKeyGenerator(new MockKeyGenerator());
|
||||
inputSource.setKeyCollector(new MockKeyGenerator());
|
||||
inputSource.setSaveState(true);
|
||||
|
||||
return inputSource;
|
||||
@@ -157,7 +157,7 @@ public class DrivingQueryItemReaderTests extends TestCase {
|
||||
|
||||
public void testRetriveZeroKeys(){
|
||||
|
||||
itemReader.setKeyGenerator(new KeyGenerator(){
|
||||
itemReader.setKeyCollector(new KeyCollector(){
|
||||
|
||||
public List retrieveKeys(ExecutionContext executionContext) {
|
||||
return new ArrayList();
|
||||
@@ -192,7 +192,7 @@ public class DrivingQueryItemReaderTests extends TestCase {
|
||||
return (ItemStream) source;
|
||||
}
|
||||
|
||||
private static class MockKeyGenerator implements KeyGenerator{
|
||||
private static class MockKeyGenerator implements KeyCollector{
|
||||
|
||||
static ExecutionContext streamContext;
|
||||
List keys;
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package org.springframework.batch.item.database;
|
||||
|
||||
import org.springframework.batch.item.ItemReader;
|
||||
import org.springframework.batch.item.database.support.IbatisKeyGenerator;
|
||||
import org.springframework.batch.item.database.support.IbatisKeyCollector;
|
||||
import org.springframework.core.io.ClassPathResource;
|
||||
import org.springframework.orm.ibatis.SqlMapClientFactoryBean;
|
||||
|
||||
@@ -23,13 +23,13 @@ public class IbatisItemReaderIntegrationTests extends AbstractDataSourceItemRead
|
||||
SqlMapClient sqlMapClient = (SqlMapClient) factory.getObject();
|
||||
|
||||
IbatisDrivingQueryItemReader inputSource = new IbatisDrivingQueryItemReader();
|
||||
IbatisKeyGenerator keyGenerator = new IbatisKeyGenerator();
|
||||
IbatisKeyCollector keyGenerator = new IbatisKeyCollector();
|
||||
keyGenerator.setDrivingQueryId("getAllFooIds");
|
||||
inputSource.setDetailsQueryId("getFooById");
|
||||
keyGenerator.setRestartQueryId("getAllFooIdsRestart");
|
||||
keyGenerator.setSqlMapClient(sqlMapClient);
|
||||
inputSource.setSqlMapClient(sqlMapClient);
|
||||
inputSource.setKeyGenerator(keyGenerator);
|
||||
inputSource.setKeyCollector(keyGenerator);
|
||||
inputSource.setSaveState(true);
|
||||
|
||||
return inputSource;
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
package org.springframework.batch.item.database;
|
||||
|
||||
import org.springframework.batch.item.ItemReader;
|
||||
import org.springframework.batch.item.database.support.MultipleColumnJdbcKeyGenerator;
|
||||
import org.springframework.batch.item.database.support.MultipleColumnJdbcKeyCollector;
|
||||
|
||||
/**
|
||||
* @author Lucas Ward
|
||||
@@ -27,14 +27,14 @@ public class MultipleColumnJdbcDrivingQueryItemReaderIntegrationTests extends
|
||||
|
||||
protected ItemReader createItemReader() throws Exception {
|
||||
|
||||
MultipleColumnJdbcKeyGenerator keyGenerator =
|
||||
new MultipleColumnJdbcKeyGenerator(getJdbcTemplate(),
|
||||
MultipleColumnJdbcKeyCollector keyGenerator =
|
||||
new MultipleColumnJdbcKeyCollector(getJdbcTemplate(),
|
||||
"SELECT ID, VALUE from T_FOOS order by ID, VALUE");
|
||||
|
||||
keyGenerator.setRestartSql("SELECT ID, VALUE from T_FOOS where ID > ? and VALUE > ? order by ID");
|
||||
DrivingQueryItemReader inputSource = new DrivingQueryItemReader();
|
||||
inputSource.setSaveState(true);
|
||||
inputSource.setKeyGenerator(keyGenerator);
|
||||
inputSource.setKeyCollector(keyGenerator);
|
||||
FooItemReader fooItemReader = new FooItemReader(inputSource, getJdbcTemplate());
|
||||
fooItemReader.setFooDao(new CompositeKeyFooDao(getJdbcTemplate()));
|
||||
return fooItemReader;
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package org.springframework.batch.item.database;
|
||||
|
||||
import org.springframework.batch.item.ItemReader;
|
||||
import org.springframework.batch.item.database.support.SingleColumnJdbcKeyGenerator;
|
||||
import org.springframework.batch.item.database.support.SingleColumnJdbcKeyCollector;
|
||||
|
||||
public class SingleColumnJdbcDrivingQueryItemReaderIntegrationTests extends AbstractJdbcItemReaderIntegrationTests {
|
||||
|
||||
@@ -13,11 +13,11 @@ public class SingleColumnJdbcDrivingQueryItemReaderIntegrationTests extends Abst
|
||||
*/
|
||||
protected ItemReader createItemReader() throws Exception {
|
||||
|
||||
SingleColumnJdbcKeyGenerator keyStrategy = new SingleColumnJdbcKeyGenerator(getJdbcTemplate(),
|
||||
SingleColumnJdbcKeyCollector keyStrategy = new SingleColumnJdbcKeyCollector(getJdbcTemplate(),
|
||||
"SELECT ID from T_FOOS order by ID");
|
||||
keyStrategy.setRestartSql("SELECT ID from T_FOOS where ID > ? order by ID");
|
||||
DrivingQueryItemReader inputSource = new DrivingQueryItemReader();
|
||||
inputSource.setKeyGenerator(keyStrategy);
|
||||
inputSource.setKeyCollector(keyStrategy);
|
||||
inputSource.setSaveState(true);
|
||||
return new FooItemReader(inputSource, getJdbcTemplate());
|
||||
|
||||
|
||||
@@ -22,7 +22,7 @@ import org.springframework.test.AbstractTransactionalDataSourceSpringContextTest
|
||||
*/
|
||||
public class MultipleColumnJdbcKeyGeneratorIntegrationTests extends AbstractTransactionalDataSourceSpringContextTests {
|
||||
|
||||
MultipleColumnJdbcKeyGenerator keyStrategy;
|
||||
MultipleColumnJdbcKeyCollector keyStrategy;
|
||||
|
||||
ExecutionContext executionContext;
|
||||
|
||||
@@ -33,7 +33,7 @@ public class MultipleColumnJdbcKeyGeneratorIntegrationTests extends AbstractTran
|
||||
protected void onSetUpBeforeTransaction() throws Exception {
|
||||
super.onSetUpBeforeTransaction();
|
||||
|
||||
keyStrategy = new MultipleColumnJdbcKeyGenerator(getJdbcTemplate(),
|
||||
keyStrategy = new MultipleColumnJdbcKeyCollector(getJdbcTemplate(),
|
||||
"SELECT ID, VALUE from T_FOOS order by ID");
|
||||
|
||||
keyStrategy.setRestartSql("SELECT ID, VALUE from T_FOOS where ID > ? and VALUE > ? order by ID");
|
||||
|
||||
@@ -12,7 +12,7 @@ import org.springframework.test.AbstractTransactionalDataSourceSpringContextTest
|
||||
*/
|
||||
public class SingleColumnJdbcKeyGeneratorIntegrationTests extends AbstractTransactionalDataSourceSpringContextTests {
|
||||
|
||||
SingleColumnJdbcKeyGenerator keyStrategy;
|
||||
SingleColumnJdbcKeyCollector keyStrategy;
|
||||
|
||||
ExecutionContext executionContext;
|
||||
|
||||
@@ -24,7 +24,7 @@ public class SingleColumnJdbcKeyGeneratorIntegrationTests extends AbstractTransa
|
||||
protected void onSetUpBeforeTransaction() throws Exception {
|
||||
super.onSetUpBeforeTransaction();
|
||||
|
||||
keyStrategy = new SingleColumnJdbcKeyGenerator(getJdbcTemplate(),
|
||||
keyStrategy = new SingleColumnJdbcKeyCollector(getJdbcTemplate(),
|
||||
"SELECT ID from T_FOOS order by ID");
|
||||
|
||||
keyStrategy.setRestartSql("SELECT ID from T_FOOS where ID > ? order by ID");
|
||||
|
||||
Reference in New Issue
Block a user