RESOLVED: BATCH-1501 - paging queries fixed for sort key not in first column of query

This commit is contained in:
dsyer
2010-02-04 10:07:10 +00:00
parent 5ed6f03756
commit 164b322173
5 changed files with 28 additions and 5 deletions

View File

@@ -115,6 +115,12 @@ public class JdbcPagingItemReader<T> extends AbstractPagingItemReader<T> impleme
this.fetchSize = fetchSize;
}
/**
* A {@link PagingQueryProvider}. Supplies all the platform dependent query
* generation capabilities needed by the reader.
*
* @param queryProvider the {@link PagingQueryProvider} to use
*/
public void setQueryProvider(PagingQueryProvider queryProvider) {
this.queryProvider = queryProvider;
}
@@ -135,7 +141,7 @@ public class JdbcPagingItemReader<T> extends AbstractPagingItemReader<T> impleme
* parameters then the key should be the name used in the query clause. If
* you use "?" placeholders then the key should be the relative index that
* the parameter appears in the query string built using the select, from
* and where cluases specified.
* and where clauses specified.
*
* @param parameterValues the values keyed by the parameter named/index used
* in the query string.
@@ -279,7 +285,7 @@ public class JdbcPagingItemReader<T> extends AbstractPagingItemReader<T> impleme
@SuppressWarnings("unchecked")
public void processRow(ResultSet rs) throws SQLException {
startAfterValue = rs.getObject(1);
startAfterValue = rs.getObject(queryProvider.getSortKey());
results.add((T) rowMapper.mapRow(rs, results.size()));
}
}

View File

@@ -75,4 +75,11 @@ public interface PagingQueryProvider {
*/
boolean isUsingNamedParameters();
/**
* The sort key (unique single column name).
*
* @return the sort key used to order the query
*/
String getSortKey();
}

View File

@@ -141,7 +141,7 @@ public abstract class AbstractSqlPagingQueryProvider implements PagingQueryProvi
*
* @return sortKey key to use to sort and limit page content
*/
protected String getSortKey() {
public String getSortKey() {
return sortKey;
}