diff --git a/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/database/DrivingQueryItemReader.java b/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/database/DrivingQueryItemReader.java
deleted file mode 100644
index 5a111117b..000000000
--- a/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/database/DrivingQueryItemReader.java
+++ /dev/null
@@ -1,177 +0,0 @@
-/*
- * Copyright 2006-2007 the original author or authors.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.springframework.batch.item.database;
-
-import java.util.Iterator;
-import java.util.List;
-
-import org.springframework.batch.item.ExecutionContext;
-import org.springframework.batch.item.ItemReader;
-import org.springframework.batch.item.ItemStream;
-import org.springframework.beans.factory.InitializingBean;
-import org.springframework.util.Assert;
-
-/**
- *
- * Convenience class for driving query item readers. Item readers of this type
- * use a 'driving query' to return back a list of keys. A key can be defined as
- * anything that can uniquely identify a record so that a more detailed record
- * can be retrieved for each object. This allows a much smaller footprint to be
- * stored in memory for processing. The following 'Customer' example table will
- * help illustrate this:
- *
- *
- * CREATE TABLE CUSTOMER (
- * ID BIGINT IDENTITY PRIMARY KEY,
- * NAME VARCHAR(45),
- * CREDIT FLOAT
- * );
- *
- *
- *
- * A cursor based solution would simply open up a cursor over ID, NAME, and
- * CREDIT, and move it from one to the next. This can cause issues on databases
- * with pessimistic locking strategies. A 'driving query' approach would be to
- * return only the ID of the customer, then use a separate DAO to retrieve the
- * name and credit for each ID. This means that there will be a call to a
- * separate DAO for each call to {@link ItemReader#read()}.
- *
- *
- *
- * Mutability: Because this base class cannot guarantee that the keys returned
- * by subclasses are immutable, care should be taken to not modify a key value.
- * Doing so would cause issues if a rollback occurs. For example, if a call to
- * read() is made, and the returned key is modified, a rollback will cause the
- * next call to read() to return the same object that was originally returned,
- * since there is no way to create a defensive copy, and re-querying the
- * database for all the keys would be too resource intensive.
- *
- *
- * The implementation is *not* thread-safe.
- *
- *
- * @author Lucas Ward
- * @deprecated The DrivingQueryItemReader approach is not supported going forward, use a PagingItemReader
- * implementation instead. See {@link org.springframework.batch.item.database.AbstractPagingItemReader}
- */
-public class DrivingQueryItemReader implements ItemReader, InitializingBean, ItemStream {
-
- private boolean initialized = false;
-
- private T currentKey = null;
-
- private Iterator keysIterator;
-
- private int currentIndex = 0;
-
- private KeyCollector keyCollector;
-
- private boolean saveState = false;
-
- public DrivingQueryItemReader() {
-
- }
-
- /**
- * Initialize the input source with the provided keys list.
- *
- * @param keys
- */
- public DrivingQueryItemReader(List keys) {
- this.keysIterator = keys.iterator();
- }
-
- /**
- * Return the next key in the List.
- *
- * @return next key in the list if not index is not at the last element,
- * null otherwise.
- */
- public T read() {
-
- if (keysIterator.hasNext()) {
- currentIndex++;
- currentKey = keysIterator.next();
- return currentKey;
- }
-
- return null;
- }
-
- /**
- * Get the current key. This method will return the same object returned by
- * the last read() method. If no items have been read yet the ItemReader
- * yet, then null will be returned.
- *
- * @return the current key.
- */
- protected T getCurrentKey() {
- return currentKey;
- }
-
- /**
- * Close the resource by setting the list of keys to null, allowing them to
- * be garbage collected.
- */
- public void close() {
- initialized = false;
- currentIndex = 0;
- keysIterator = null;
- }
-
- /**
- * Initialize the item reader by delegating to the subclass in order to
- * retrieve the keys.
- *
- * @throws IllegalStateException if the keys list is null or initialized is
- * true.
- */
- public void open(ExecutionContext executionContext) {
-
- Assert.state(keysIterator == null && !initialized, "Cannot open an already opened item reader"
- + ", call close() first.");
- List keys = keyCollector.retrieveKeys(executionContext);
- Assert.notNull(keys, "Keys must not be null");
- keysIterator = keys.listIterator();
- initialized = true;
- }
-
- public void update(ExecutionContext executionContext) {
- if (saveState) {
- Assert.notNull(executionContext, "ExecutionContext must not be null");
- if (getCurrentKey() != null) {
- keyCollector.updateContext(getCurrentKey(), executionContext);
- }
- }
- }
-
- public void afterPropertiesSet() throws Exception {
- Assert.notNull(keyCollector, "The KeyGenerator must not be null.");
- }
-
- /**
- * Set the key generation strategy to use for this input source.
- *
- * @param keyCollector
- */
- public void setKeyCollector(KeyCollector keyCollector) {
- this.keyCollector = keyCollector;
- }
-
- public void setSaveState(boolean saveState) {
- this.saveState = saveState;
- }
-}
diff --git a/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/database/IbatisDrivingQueryItemReader.java b/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/database/IbatisDrivingQueryItemReader.java
deleted file mode 100644
index cb3cc3c1b..000000000
--- a/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/database/IbatisDrivingQueryItemReader.java
+++ /dev/null
@@ -1,76 +0,0 @@
-/*
- * Copyright 2006-2007 the original author or authors.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.springframework.batch.item.database;
-
-import org.springframework.batch.item.database.support.IbatisKeyCollector;
-import org.springframework.orm.ibatis.SqlMapClientTemplate;
-
-import com.ibatis.sqlmap.client.SqlMapClient;
-
-/**
- * Extension of {@link DrivingQueryItemReader} that maps keys to objects. An
- * iBatis query id must be set to map and return each 'detail record'.
- *
- * The writer is thread safe after its properties are set (normal singleton
- * behaviour).
- *
- * TODO remove this class? It does not return keys so it shouldn't extend
- * DrivingQueryItemReader
- *
- * @author Lucas Ward
- * @see IbatisKeyCollector
- * @deprecated The DrivingQueryItemReader approach is not supported going forward, use a PagingItemReader
- * implementation instead. See {@link org.springframework.batch.item.database.AbstractPagingItemReader}
- */
-@SuppressWarnings("unchecked")
-public class IbatisDrivingQueryItemReader extends DrivingQueryItemReader {
-
- private String detailsQueryId;
-
- private SqlMapClientTemplate sqlMapClientTemplate;
-
- /**
- * Overridden read() that uses the returned key as arguments to the details
- * query.
- *
- * @see org.springframework.batch.item.database.DrivingQueryItemReader#read()
- */
- public Object read() {
- Object key = super.read();
- if (key == null) {
- return null;
- }
- return sqlMapClientTemplate.queryForObject(detailsQueryId, key);
- }
-
- /**
- * @param detailsQueryId id of the iBATIS select statement that will used to
- * retrieve an object for a single primary key from the list returned by
- * driving query
- */
- public void setDetailsQueryId(String detailsQueryId) {
- this.detailsQueryId = detailsQueryId;
- }
-
- /**
- * Set the {@link SqlMapClientTemplate} to use for this input source.
- *
- * @param sqlMapClient
- */
- public void setSqlMapClient(SqlMapClient sqlMapClient) {
- this.sqlMapClientTemplate = new SqlMapClientTemplate(sqlMapClient);
- }
-}
diff --git a/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/database/KeyCollector.java b/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/database/KeyCollector.java
deleted file mode 100644
index 8cacde167..000000000
--- a/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/database/KeyCollector.java
+++ /dev/null
@@ -1,64 +0,0 @@
-/*
- * Copyright 2006-2007 the original author or authors.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.springframework.batch.item.database;
-
-import java.util.List;
-
-import org.springframework.batch.item.ExecutionContext;
-
-/**
- * Strategy interface used to collect keys in driving query input.
- *
- * @author Lucas Ward
- * @see DrivingQueryItemReader
- * @deprecated The DrivingQueryItemReader approach is not supported going forward, use a PagingItemReader
- * implementation instead. See {@link org.springframework.batch.item.database.AbstractPagingItemReader}
- */
-public interface KeyCollector {
-
- /**
- * Retrieve the keys to be iterated over. If the ExecutionContext
- * provided includes any state relevant to this collector (because it was
- * stored as part of saveState()) then it should start from the point
- * indicated by that state.
- *
- * In the case of a restart, (i.e. the ExecutionContext contains relevant state)
- * this method should return only the keys that are remaining to be processed. For
- * example, if the are 1,000 keys, and the 500th is processed before the batch job
- * terminates unexpectedly, upon restart keys 501 through 1,000 should be returned.
- *
- *
- * @param executionContext ExecutionContext containing any potential initial state
- * that could potentially be used to retrieve the correct keys.
- * @return list of keys returned by the driving query (can be empty but not null)
- */
- List retrieveKeys(ExecutionContext executionContext);
-
- /**
- * Given the provided key, store it in the provided ExecutionContext. This
- * is necessary because retrieveKeys() will be called with the ExecutionContext
- * that is provided as a result of this method. Since only the KeyCollector
- * can know what format the ExecutionContext should be in, it should also
- * save the state, as opposed to the {@link DrivingQueryItemReader} doing it
- * for all KeyCollector implementations.
- *
- * @param key to be converted to restart data.
- * @throws IllegalArgumentException if key is null.
- * @throws IllegalArgumentException if key is an incompatible type.
- */
- void updateContext(T key, ExecutionContext executionContext);
-}
diff --git a/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/database/support/IbatisKeyCollector.java b/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/database/support/IbatisKeyCollector.java
deleted file mode 100644
index 681e657a1..000000000
--- a/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/database/support/IbatisKeyCollector.java
+++ /dev/null
@@ -1,129 +0,0 @@
-/*
- * Copyright 2006-2007 the original author or authors.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.springframework.batch.item.database.support;
-
-import java.util.List;
-
-import org.springframework.batch.item.ExecutionContext;
-import org.springframework.batch.item.database.DrivingQueryItemReader;
-import org.springframework.batch.item.database.KeyCollector;
-import org.springframework.batch.item.util.ExecutionContextUserSupport;
-import org.springframework.orm.ibatis.SqlMapClientTemplate;
-import org.springframework.util.Assert;
-import org.springframework.util.ClassUtils;
-
-import com.ibatis.sqlmap.client.SqlMapClient;
-
-/**
- * {@link KeyCollector} based on iBATIS ORM framework. It is functionally
- * similar to {@link SingleColumnJdbcKeyCollector} but does not make assumptions
- * about the primary key structure. A separate restart query is necessary to
- * ensure that only the required keys remaining for processing are returned,
- * rather than the entire original list.
- *
- * The writer is thread safe after its properties are set (normal singleton
- * behaviour).
- *
- * @author Robert Kasanicky
- * @author Lucas Ward
- * @see DrivingQueryItemReader
- * @deprecated The DrivingQueryItemReader approach is not supported going forward, use a PagingItemReader
- * implementation instead. See {@link org.springframework.batch.item.database.AbstractPagingItemReader}
- */
-public class IbatisKeyCollector extends ExecutionContextUserSupport implements KeyCollector {
-
- private static final String RESTART_KEY = "key.index";
-
- private SqlMapClientTemplate sqlMapClientTemplate;
-
- private String drivingQuery;
-
- private String restartQueryId;
-
- public IbatisKeyCollector() {
- setName(ClassUtils.getShortName(IbatisKeyCollector.class));
- }
-
- /*
- * Retrieve the keys using the provided driving query id.
- *
- * @see KeyCollector#retrieveKeys()
- */
- @SuppressWarnings("unchecked")
- public List retrieveKeys(ExecutionContext executionContext) {
- if (executionContext.containsKey(getKey(RESTART_KEY))) {
- Object key = executionContext.get(getKey(RESTART_KEY));
- return sqlMapClientTemplate.queryForList(restartQueryId, key);
- }
- else {
- return sqlMapClientTemplate.queryForList(drivingQuery);
- }
- }
-
- /*
- * (non-Javadoc)
- *
- * @see KeyCollector#saveState(Object, ExecutionContext)
- */
- public void updateContext(T key, ExecutionContext executionContext) {
- Assert.notNull(key, "Key must not be null");
- Assert.notNull(executionContext, "ExecutionContext must be null");
- executionContext.put(getKey(RESTART_KEY), key);
- }
-
- /*
- * (non-Javadoc)
- *
- * @see
- * org.springframework.beans.factory.InitializingBean#afterPropertiesSet()
- */
- public void afterPropertiesSet() throws Exception {
- Assert.notNull(sqlMapClientTemplate, "SqlMaperClientTemplate must not be null.");
- Assert.hasText(drivingQuery, "The DrivingQuery must not be null or empty.");
- }
-
- /**
- * @param sqlMapClient configured iBATIS client
- */
- public void setSqlMapClient(SqlMapClient sqlMapClient) {
- this.sqlMapClientTemplate = new SqlMapClientTemplate();
- this.sqlMapClientTemplate.setSqlMapClient(sqlMapClient);
- }
-
- /**
- * @param drivingQueryId id of the iBATIS select statement that will be used
- * to retrieve the list of primary keys
- */
- public void setDrivingQueryId(String drivingQueryId) {
- this.drivingQuery = drivingQueryId;
- }
-
- /**
- * Set the id of the restart query.
- *
- * @param restartQueryId id of the iBatis select statement that will be used
- * to retrieve the list of primary keys after a restart.
- */
- public void setRestartQueryId(String restartQueryId) {
- this.restartQueryId = restartQueryId;
- }
-
- public final SqlMapClientTemplate getSqlMapClientTemplate() {
- return sqlMapClientTemplate;
- }
-
-}
diff --git a/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/database/support/MultipleColumnJdbcKeyCollector.java b/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/database/support/MultipleColumnJdbcKeyCollector.java
deleted file mode 100644
index dc18ba690..000000000
--- a/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/database/support/MultipleColumnJdbcKeyCollector.java
+++ /dev/null
@@ -1,191 +0,0 @@
-/*
- * Copyright 2006-2007 the original author or authors.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.springframework.batch.item.database.support;
-
-import java.sql.PreparedStatement;
-import java.sql.SQLException;
-import java.util.List;
-
-import org.springframework.batch.item.ExecutionContext;
-import org.springframework.batch.item.database.DrivingQueryItemReader;
-import org.springframework.batch.item.database.ItemPreparedStatementSetter;
-import org.springframework.batch.item.database.KeyCollector;
-import org.springframework.batch.item.util.ExecutionContextUserSupport;
-import org.springframework.jdbc.core.ColumnMapRowMapper;
-import org.springframework.jdbc.core.PreparedStatementSetter;
-import org.springframework.jdbc.core.RowMapper;
-import org.springframework.jdbc.core.JdbcOperations;
-import org.springframework.util.Assert;
-import org.springframework.util.ClassUtils;
-import org.springframework.util.StringUtils;
-
-/**
- *
- * JDBC implementation of the {@link KeyCollector} interface that works for
- * composite keys. (i.e. keys represented by multiple columns) A SQL query to be
- * used to return the keys and a {@link ItemPreparedStatementSetter} to map each
- * row in the result set to an Object must be set in order to work correctly.
- *
- *
- * The implementation is thread-safe as long as the
- * {@link #setPreparedStatementSetter(ItemPreparedStatementSetter)} and
- * {@link #setKeyMapper(RowMapper)} are thread-safe (true for default values).
- *
- *
- * @author Lucas Ward
- *
- * @see DrivingQueryItemReader
- * @see ItemPreparedStatementSetter
- *
- * TODO this class has nothing to do with "multiple columns" other than default
- * values form keyMapper and preparedStatementSetter. This should be sorted out for 2.0
- * @deprecated The DrivingQueryItemReader approach is not supported going forward, use a PagingItemReader
- * implementation instead. See {@link org.springframework.batch.item.database.AbstractPagingItemReader}
- */
-public class MultipleColumnJdbcKeyCollector extends ExecutionContextUserSupport implements KeyCollector {
-
- private static final String CURRENT_KEY = "current.key";
-
- private JdbcOperations jdbcTemplate;
-
- private RowMapper keyMapper = new ColumnMapRowMapper();
-
- @SuppressWarnings("unchecked")
- private ItemPreparedStatementSetter preparedStatementSetter = new ColumnMapItemPreparedStatementSetter();
-
- private String sql;
-
- private String restartSql;
-
- public MultipleColumnJdbcKeyCollector() {
- setName(ClassUtils.getShortName(MultipleColumnJdbcKeyCollector.class));
- }
-
- /**
- * Construct a new ItemReader.
- *
- * @param jdbcTemplate
- * @param sql - SQL statement that returns all keys to process. object.
- */
- public MultipleColumnJdbcKeyCollector(JdbcOperations jdbcTemplate, String sql) {
- this();
- Assert.notNull(jdbcTemplate, "The JdbcTemplate must not be null.");
- Assert.hasText(sql, "The sql statement must not be null or empty.");
- this.jdbcTemplate = jdbcTemplate;
- this.sql = sql;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see
- * org.springframework.batch.io.sql.scratch.AbstractDrivingQueryItemReader
- * #retrieveKeys()
- */
- @SuppressWarnings("unchecked")
- public List retrieveKeys(ExecutionContext executionContext) {
-
- Assert.state(keyMapper != null, "KeyMapper must not be null.");
- Assert.state(StringUtils.hasText(restartSql), "The RestartQuery must not be null or empty"
- + " in order to restart.");
-
- if (executionContext.size() > 0) {
- T key = (T) executionContext.get(getKey(CURRENT_KEY));
- return jdbcTemplate.query(restartSql, new PreparedStatementSetterKeyWrapper(key, preparedStatementSetter),
- keyMapper);
- }
- else {
- return jdbcTemplate.query(sql, keyMapper);
- }
- }
-
- /*
- * (non-Javadoc)
- *
- * @see
- * org.springframework.batch.io.driving.KeyGenerator#getKeyAsExecutionContext
- * (java.lang.Object)
- */
- public void updateContext(T key, ExecutionContext executionContext) {
- Assert.notNull(key, "The key must not be null");
- Assert.notNull(executionContext, "The ExecutionContext must not be null");
- executionContext.put(getKey(CURRENT_KEY), key);
- }
-
- /**
- * Set the query to use to retrieve keys in order to restore the previous
- * state for restart.
- *
- * @param restartQuery
- */
- public void setRestartSql(String restartQuery) {
- this.restartSql = restartQuery;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see
- * org.springframework.beans.factory.InitializingBean#afterPropertiesSet()
- */
- public void afterPropertiesSet() throws Exception {
- Assert.notNull(jdbcTemplate, "The JdbcTemplate must not be null.");
- Assert.hasText(sql, "The DrivingQuery must not be null or empty.");
- Assert.notNull(keyMapper, "The key RowMapper must not be null.");
- }
-
- /**
- * Set the {@link RowMapper} to be used to map a result set to keys.
- *
- * @param keyMapper
- */
- public void setKeyMapper(RowMapper keyMapper) {
- this.keyMapper = keyMapper;
- }
-
- /**
- * Set the sql statement used to generate the keys list.
- *
- * @param sql
- */
- public void setSql(String sql) {
- this.sql = sql;
- }
-
- public void setJdbcTemplate(JdbcOperations jdbcTemplate) {
- this.jdbcTemplate = jdbcTemplate;
- }
-
- public void setPreparedStatementSetter(ItemPreparedStatementSetter preparedStatementSetter) {
- this.preparedStatementSetter = preparedStatementSetter;
- }
-
- private class PreparedStatementSetterKeyWrapper implements PreparedStatementSetter {
-
- private T key;
-
- private ItemPreparedStatementSetter pss;
-
- public PreparedStatementSetterKeyWrapper(T key, ItemPreparedStatementSetter pss) {
- this.key = key;
- this.pss = pss;
- }
-
- public void setValues(PreparedStatement ps) throws SQLException {
- pss.setValues(key, ps);
- }
- }
-}
diff --git a/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/database/support/SingleColumnJdbcKeyCollector.java b/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/database/support/SingleColumnJdbcKeyCollector.java
deleted file mode 100644
index bbf40af57..000000000
--- a/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/database/support/SingleColumnJdbcKeyCollector.java
+++ /dev/null
@@ -1,170 +0,0 @@
-/*
- * Copyright 2006-2007 the original author or authors.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.springframework.batch.item.database.support;
-
-import java.util.List;
-
-import org.springframework.batch.item.ExecutionContext;
-import org.springframework.batch.item.database.KeyCollector;
-import org.springframework.batch.item.util.ExecutionContextUserSupport;
-import org.springframework.jdbc.core.RowMapper;
-import org.springframework.jdbc.core.SingleColumnRowMapper;
-import org.springframework.jdbc.core.JdbcOperations;
-import org.springframework.util.Assert;
-import org.springframework.util.ClassUtils;
-import org.springframework.util.StringUtils;
-
-/**
- *
- * Jdbc {@link KeyCollector} implementation that only works for a single column
- * key. A sql query must be passed in which will be used to return a list of
- * keys. Each key will be mapped by a {@link RowMapper} that returns a mapped
- * key. By default, the {@link SingleColumnRowMapper} is used, and will convert
- * keys into well known types at runtime. It is extremely important to note that
- * only one column should be mapped to an object and returned as a key. If
- * multiple columns are returned as a key in this strategy, then restart will
- * not function properly. Instead a strategy that supports keys comprised of
- * multiple columns should be used.
- *
- *
- *
- * Restartability: Because the key is only one column, restart is made much more
- * simple. Before each commit, the last processed key is returned to be stored
- * as restart data. Upon restart, that same key is given back to restore from,
- * using a separate 'RestartQuery'. This means that only the keys remaining to
- * be processed are returned, rather than returning the original list of keys
- * and iterating forward to that last committed point.
- *
- *
- * @author Lucas Ward
- * @see SingleColumnRowMapper
- * @deprecated The DrivingQueryItemReader approach is not supported going forward, use a PagingItemReader
- * implementation instead. See {@link org.springframework.batch.item.database.AbstractPagingItemReader}
- */
-public class SingleColumnJdbcKeyCollector extends ExecutionContextUserSupport implements KeyCollector {
-
- private static final String RESTART_KEY = "key";
-
- private JdbcOperations jdbcTemplate;
-
- private String sql;
-
- private String restartSql;
-
- private RowMapper keyMapper = new SingleColumnRowMapper();
-
- public SingleColumnJdbcKeyCollector() {
- setName(ClassUtils.getShortName(SingleColumnJdbcKeyCollector.class));
- }
-
- /**
- * Constructs a new instance using the provided jdbcTemplate and string
- * representing the sql statement that should be used to retrieve keys.
- *
- * @param jdbcTemplate
- * @param sql
- * @throws IllegalArgumentException if jdbcTemplate is null.
- * @throws IllegalArgumentException if sql string is empty or null.
- */
- public SingleColumnJdbcKeyCollector(JdbcOperations jdbcTemplate, String sql) {
- this();
- Assert.notNull(jdbcTemplate, "JdbcTemplate must not be null.");
- Assert.hasText(sql, "The sql statement must not be null or empty.");
- this.jdbcTemplate = jdbcTemplate;
- this.sql = sql;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see
- * org.springframework.batch.io.driving.KeyGenerationStrategy#retrieveKeys()
- */
- @SuppressWarnings("unchecked")
- public List retrieveKeys(ExecutionContext executionContext) {
-
- Assert.notNull(executionContext, "The ExecutionContext must not be null");
-
- if (executionContext.containsKey(getKey(RESTART_KEY))) {
- Assert.state(StringUtils.hasText(restartSql), "The restart sql query must not be null or empty"
- + " in order to restart.");
- return jdbcTemplate
- .query(restartSql, new Object[] { executionContext.get(getKey(RESTART_KEY)) }, keyMapper);
- }
- else {
- return jdbcTemplate.query(sql, keyMapper);
- }
- }
-
- /**
- * Get the restart data representing the last processed key.
- *
- * @throws IllegalArgumentException if key is null.
- */
- public void updateContext(T key, ExecutionContext executionContext) {
- Assert.notNull(key, "The key must not be null.");
- Assert.notNull(executionContext, "The ExecutionContext must not be null");
- executionContext.put(getKey(RESTART_KEY), key);
- }
-
- /*
- * (non-Javadoc)
- *
- * @see
- * org.springframework.beans.factory.InitializingBean#afterPropertiesSet()
- */
- public void afterPropertiesSet() throws Exception {
- Assert.notNull(jdbcTemplate, "JdbcTemplate must not be null.");
- Assert.hasText(sql, "The DrivingQuery must not be null or empty.");
- }
-
- /**
- * Set the {@link RowMapper} to be used to map each key to an object.
- *
- * @param keyMapper
- */
- public void setKeyMapper(RowMapper keyMapper) {
- this.keyMapper = keyMapper;
- }
-
- /**
- * Set the SQL query to be used to return the remaining keys to be
- * processed.
- *
- * @param restartSql
- */
- public void setRestartSql(String restartSql) {
- this.restartSql = restartSql;
- }
-
- /**
- * Set the SQL statement to be used to return the keys to be processed.
- *
- * @param sql
- */
- public void setSql(String sql) {
- this.sql = sql;
- }
-
- /**
- * Set the {@link JdbcOperations} to be used.
- *
- * @param jdbcTemplate
- */
- public void setJdbcTemplate(JdbcOperations jdbcTemplate) {
- this.jdbcTemplate = jdbcTemplate;
- }
-}
diff --git a/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/database/DrivingQueryItemReaderTests.java b/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/database/DrivingQueryItemReaderTests.java
deleted file mode 100644
index 4043c590f..000000000
--- a/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/database/DrivingQueryItemReaderTests.java
+++ /dev/null
@@ -1,206 +0,0 @@
-package org.springframework.batch.item.database;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import junit.framework.TestCase;
-
-import org.springframework.batch.item.ExecutionContext;
-import org.springframework.batch.item.ItemReader;
-import org.springframework.batch.item.ItemStream;
-import org.springframework.batch.item.sample.Foo;
-import org.springframework.beans.factory.InitializingBean;
-
-@SuppressWarnings("deprecation")
-public class DrivingQueryItemReaderTests extends TestCase {
-
- DrivingQueryItemReader itemReader;
-
- protected void setUp() throws Exception {
- super.setUp();
-
- itemReader = createItemReader();
- }
-
- private DrivingQueryItemReader createItemReader() throws Exception {
-
- DrivingQueryItemReader inputSource = new DrivingQueryItemReader();
- inputSource.setKeyCollector(new MockKeyGenerator());
- inputSource.setSaveState(true);
-
- return inputSource;
- }
-
- /**
- * Regular scenario - read all rows and eventually return null.
- */
- public void testNormalProcessing() throws Exception {
- getAsInitializingBean(itemReader).afterPropertiesSet();
- getAsItemStream(itemReader).open(new ExecutionContext());
-
- Foo foo1 = (Foo) itemReader.read();
- assertEquals(1, foo1.getValue());
-
- Foo foo2 = (Foo) itemReader.read();
- assertEquals(2, foo2.getValue());
-
- Foo foo3 = (Foo) itemReader.read();
- assertEquals(3, foo3.getValue());
-
- Foo foo4 = (Foo) itemReader.read();
- assertEquals(4, foo4.getValue());
-
- Foo foo5 = (Foo) itemReader.read();
- assertEquals(5, foo5.getValue());
-
- assertNull(itemReader.read());
- }
-
- /**
- * Restart scenario.
- *
- * @throws Exception
- */
- public void testRestart() throws Exception {
-
- ExecutionContext executionContext = new ExecutionContext();
-
- getAsItemStream(itemReader).open(executionContext);
-
- Foo foo1 = (Foo) itemReader.read();
- assertEquals(1, foo1.getValue());
-
- Foo foo2 = (Foo) itemReader.read();
- assertEquals(2, foo2.getValue());
-
- getAsItemStream(itemReader).update(executionContext);
-
- // create new input source
- itemReader = createItemReader();
-
- getAsItemStream(itemReader).open(executionContext);
-
- Foo fooAfterRestart = (Foo) itemReader.read();
- assertEquals(3, fooAfterRestart.getValue());
- }
-
- /**
- * Reading from an input source and then trying to restore causes an error.
- */
- public void testInvalidRestore() throws Exception {
-
- ExecutionContext executionContext = new ExecutionContext();
-
- getAsItemStream(itemReader).open(executionContext);
-
- Foo foo1 = (Foo) itemReader.read();
- assertEquals(1, foo1.getValue());
-
- Foo foo2 = (Foo) itemReader.read();
- assertEquals(2, foo2.getValue());
-
- getAsItemStream(itemReader).update(executionContext);
-
- // create new input source
- itemReader = createItemReader();
- getAsItemStream(itemReader).open(new ExecutionContext());
-
- Foo foo = (Foo) itemReader.read();
- assertEquals(1, foo.getValue());
-
- try {
- getAsItemStream(itemReader).open(executionContext);
- fail();
- } catch (IllegalStateException ex) {
- // expected
- }
- }
-
- /**
- * Empty restart data should be handled gracefully.
- *
- * @throws Exception
- */
- public void testRestoreFromEmptyData() throws Exception {
- ExecutionContext streamContext = new ExecutionContext(new ExecutionContext());
-
- getAsItemStream(itemReader).open(streamContext);
-
- Foo foo = (Foo) itemReader.read();
- assertEquals(1, foo.getValue());
- }
-
- public void testRetriveZeroKeys() {
-
- itemReader.setKeyCollector(new KeyCollector() {
-
- public List retrieveKeys(ExecutionContext executionContext) {
- return new ArrayList();
- }
-
- public void updateContext(Foo key,
- ExecutionContext executionContext) {
- }
- });
-
- itemReader.open(new ExecutionContext());
-
- assertNull(itemReader.read());
-
- }
-
- private InitializingBean getAsInitializingBean(ItemReader source) {
- return (InitializingBean) source;
- }
-
- private ItemStream getAsItemStream(ItemReader source) {
- return (ItemStream) source;
- }
-
- private static class MockKeyGenerator implements KeyCollector {
-
- static ExecutionContext streamContext;
- List keys;
- List restartKeys;
- static final String RESTART_KEY = "restart.keys";
-
- static {
- // restart data properties cannot be empty.
- streamContext = new ExecutionContext();
- streamContext.put("", "");
- }
-
- public MockKeyGenerator() {
-
- keys = new ArrayList();
- keys.add(new Foo(1, "1", 1));
- keys.add(new Foo(2, "2", 2));
- keys.add(new Foo(3, "3", 3));
- keys.add(new Foo(4, "4", 4));
- keys.add(new Foo(5, "5", 5));
-
- restartKeys = new ArrayList();
- restartKeys.add(new Foo(3, "3", 3));
- restartKeys.add(new Foo(4, "4", 4));
- restartKeys.add(new Foo(5, "5", 5));
- }
-
- public ExecutionContext saveState(Object key) {
- return streamContext;
- }
-
- public List retrieveKeys(ExecutionContext executionContext) {
- if (executionContext.containsKey(RESTART_KEY)) {
- return restartKeys;
- } else {
- return keys;
- }
- }
-
- public void updateContext(Foo key, ExecutionContext executionContext) {
- executionContext.put(RESTART_KEY, restartKeys);
- }
-
- }
-
-}
diff --git a/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/database/FooInputSource.java b/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/database/FooInputSource.java
deleted file mode 100644
index 971aeb188..000000000
--- a/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/database/FooInputSource.java
+++ /dev/null
@@ -1,61 +0,0 @@
-package org.springframework.batch.item.database;
-
-import javax.sql.DataSource;
-
-import org.springframework.batch.item.ExecutionContext;
-import org.springframework.batch.item.ItemReader;
-import org.springframework.batch.item.ItemStream;
-import org.springframework.batch.item.sample.Foo;
-import org.springframework.beans.factory.DisposableBean;
-import org.springframework.beans.factory.InitializingBean;
-
-@SuppressWarnings("deprecation")
-class FooItemReader implements ItemStream, ItemReader, DisposableBean, InitializingBean {
-
- DrivingQueryItemReader> itemReader;
-
- public void setItemReader(DrivingQueryItemReader> itemReader) {
- this.itemReader = itemReader;
- }
-
- FooDao fooDao = new SingleKeyFooDao();
-
- public FooItemReader(DrivingQueryItemReader> inputSource, DataSource dataSource) {
- this.itemReader = inputSource;
- fooDao.setDataSource(dataSource);
- }
-
- public Foo read() {
- Object key = itemReader.read();
- if (key != null) {
- return fooDao.getFoo(key);
- }
- else {
- return null;
- }
- }
-
- public void update(ExecutionContext executionContext) {
- itemReader.update(executionContext);
- }
-
- public void destroy() throws Exception {
- itemReader.close();
- }
-
- public void setFooDao(FooDao fooDao) {
- this.fooDao = fooDao;
- }
-
- public void afterPropertiesSet() throws Exception {
- }
-
- public void open(ExecutionContext executionContext) {
- itemReader.open(executionContext);
- }
-
- public void close() {
- itemReader.close();
- }
-
-}
diff --git a/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/database/IbatisItemReaderCommonTests.java b/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/database/IbatisItemReaderCommonTests.java
deleted file mode 100644
index b950967f7..000000000
--- a/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/database/IbatisItemReaderCommonTests.java
+++ /dev/null
@@ -1,60 +0,0 @@
-package org.springframework.batch.item.database;
-
-import org.springframework.batch.item.ExecutionContext;
-import org.springframework.batch.item.ItemReader;
-import org.springframework.batch.item.database.support.IbatisKeyCollector;
-import org.springframework.batch.item.sample.Foo;
-import org.springframework.core.io.ClassPathResource;
-import org.springframework.orm.ibatis.SqlMapClientFactoryBean;
-import org.junit.runner.RunWith;
-import org.junit.internal.runners.JUnit4ClassRunner;
-
-import com.ibatis.sqlmap.client.SqlMapClient;
-
-@SuppressWarnings({"unchecked", "deprecation"})
-@RunWith(JUnit4ClassRunner.class)
-public class IbatisItemReaderCommonTests extends AbstractDatabaseItemStreamItemReaderTests {
-
- protected ItemReader getItemReader() throws Exception {
- SqlMapClientFactoryBean factory = new SqlMapClientFactoryBean();
- factory.setConfigLocation(new ClassPathResource("ibatis-config.xml", getClass()));
- factory.setDataSource(getDataSource());
- factory.afterPropertiesSet();
- SqlMapClient sqlMapClient = createSqlMapClient();
-
- IbatisDrivingQueryItemReader reader = new IbatisDrivingQueryItemReader();
- IbatisKeyCollector keyGenerator = new IbatisKeyCollector();
- keyGenerator.setDrivingQueryId("getAllFooIds");
- reader.setDetailsQueryId("getFooById");
- keyGenerator.setRestartQueryId("getAllFooIdsRestart");
- keyGenerator.setSqlMapClient(sqlMapClient);
- reader.setSqlMapClient(sqlMapClient);
- reader.setKeyCollector(keyGenerator);
- reader.setSaveState(true);
-
- return reader;
- }
-
- private SqlMapClient createSqlMapClient() throws Exception {
- SqlMapClientFactoryBean factory = new SqlMapClientFactoryBean();
- factory.setConfigLocation(new ClassPathResource("ibatis-config.xml", getClass()));
- factory.setDataSource(getDataSource());
- factory.afterPropertiesSet();
- return (SqlMapClient) factory.getObject();
- }
-
- protected void pointToEmptyInput(ItemReader tested) throws Exception {
- IbatisDrivingQueryItemReader reader = (IbatisDrivingQueryItemReader) tested;
- reader.close();
-
- IbatisKeyCollector keyCollector = new IbatisKeyCollector();
- keyCollector.setDrivingQueryId("getNoFoos");
- keyCollector.setSqlMapClient(createSqlMapClient());
-
- reader.setKeyCollector(keyCollector);
- reader.afterPropertiesSet();
-
- reader.open(new ExecutionContext());
- }
-
-}
diff --git a/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/database/IbatisItemReaderIntegrationTests.java b/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/database/IbatisItemReaderIntegrationTests.java
deleted file mode 100644
index fbcc4f755..000000000
--- a/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/database/IbatisItemReaderIntegrationTests.java
+++ /dev/null
@@ -1,48 +0,0 @@
-package org.springframework.batch.item.database;
-
-import org.junit.runner.RunWith;
-import org.springframework.batch.item.ItemReader;
-import org.springframework.batch.item.database.support.IbatisKeyCollector;
-import org.springframework.batch.item.sample.Foo;
-import org.springframework.core.io.ClassPathResource;
-import org.springframework.orm.ibatis.SqlMapClientFactoryBean;
-import org.springframework.test.context.ContextConfiguration;
-import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
-
-import com.ibatis.sqlmap.client.SqlMapClient;
-
-/**
- * Tests for {@link IbatisDrivingQueryItemReader}
- *
- * @author Robert Kasanicky
- *
- * @deprecated
- */
-@SuppressWarnings("unchecked")
-@RunWith(SpringJUnit4ClassRunner.class)
-@ContextConfiguration(locations = "data-source-context.xml")
-public class IbatisItemReaderIntegrationTests extends AbstractDataSourceItemReaderIntegrationTests {
-
- protected ItemReader createItemReader() throws Exception {
-
- SqlMapClientFactoryBean factory = new SqlMapClientFactoryBean();
- factory.setConfigLocation(new ClassPathResource("ibatis-config.xml", getClass()));
- factory.setDataSource(dataSource);
- factory.afterPropertiesSet();
- SqlMapClient sqlMapClient = (SqlMapClient) factory.getObject();
-
- IbatisDrivingQueryItemReader inputSource = new IbatisDrivingQueryItemReader();
- IbatisKeyCollector keyGenerator = new IbatisKeyCollector();
- keyGenerator.setDrivingQueryId("getAllFooIds");
- inputSource.setDetailsQueryId("getFooById");
- keyGenerator.setRestartQueryId("getAllFooIdsRestart");
- keyGenerator.setSqlMapClient(sqlMapClient);
- inputSource.setSqlMapClient(sqlMapClient);
- inputSource.setKeyCollector(keyGenerator);
- inputSource.setSaveState(true);
-
- return inputSource;
- }
-
-
-}
diff --git a/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/database/MultipleColumnJdbcDrivingQueryItemReaderIntegrationTests.java b/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/database/MultipleColumnJdbcDrivingQueryItemReaderIntegrationTests.java
deleted file mode 100644
index 5f14f6ed4..000000000
--- a/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/database/MultipleColumnJdbcDrivingQueryItemReaderIntegrationTests.java
+++ /dev/null
@@ -1,52 +0,0 @@
-/*
- * Copyright 2006-2007 the original author or authors.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.springframework.batch.item.database;
-
-import java.util.Map;
-
-import org.junit.runner.RunWith;
-import org.springframework.batch.item.ItemReader;
-import org.springframework.batch.item.database.support.MultipleColumnJdbcKeyCollector;
-import org.springframework.batch.item.sample.Foo;
-import org.springframework.test.context.ContextConfiguration;
-import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
-
-/**
- * @author Lucas Ward
- *
- */
-@RunWith(SpringJUnit4ClassRunner.class)
-@ContextConfiguration(locations = "data-source-context.xml")
-@SuppressWarnings("deprecation")
-public class MultipleColumnJdbcDrivingQueryItemReaderIntegrationTests extends
- AbstractJdbcItemReaderIntegrationTests {
-
- protected ItemReader createItemReader() throws Exception {
-
- MultipleColumnJdbcKeyCollector