diff --git a/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/database/JdbcPagingItemReader.java b/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/database/JdbcPagingItemReader.java index 805e6af67..1aec29224 100644 --- a/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/database/JdbcPagingItemReader.java +++ b/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/database/JdbcPagingItemReader.java @@ -1,5 +1,5 @@ /* - * Copyright 2006-2013 the original author or authors. + * Copyright 2006-2018 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. @@ -51,7 +51,8 @@ import org.springframework.util.ClassUtils; * needed as {@link #read()} method is called, returning an object corresponding * to current position. On restart it uses the last sort key value to locate the * first page to read (so it doesn't matter if the successfully processed items - * have been removed or modified). + * have been removed or modified). It is important to have a unique key constraint on the + * sort key to guarantee that no data is lost between executions. *
* *
diff --git a/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/database/support/AbstractSqlPagingQueryProvider.java b/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/database/support/AbstractSqlPagingQueryProvider.java
index d71d6e030..5dfd788ce 100644
--- a/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/database/support/AbstractSqlPagingQueryProvider.java
+++ b/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/database/support/AbstractSqlPagingQueryProvider.java
@@ -16,6 +16,12 @@
package org.springframework.batch.item.database.support;
+import java.util.ArrayList;
+import java.util.LinkedHashMap;
+import java.util.List;
+import java.util.Map;
+import javax.sql.DataSource;
+
import org.springframework.batch.item.database.JdbcParameterUtils;
import org.springframework.batch.item.database.Order;
import org.springframework.batch.item.database.PagingQueryProvider;
@@ -23,12 +29,6 @@ import org.springframework.dao.InvalidDataAccessApiUsageException;
import org.springframework.util.Assert;
import org.springframework.util.StringUtils;
-import javax.sql.DataSource;
-import java.util.ArrayList;
-import java.util.LinkedHashMap;
-import java.util.List;
-import java.util.Map;
-
/**
* Abstract SQL Paging Query Provider to serve as a base class for all provided
* SQL paging query providers.
@@ -42,7 +42,9 @@ import java.util.Map;
* Provides properties and preparation for the mandatory "selectClause" and
* "fromClause" as well as for the optional "whereClause". Also provides
* property for the mandatory "sortKeys". Note: The columns that make up
- * the sort key must be a true key and not just a column to order by.
+ * the sort key must be a true key and not just a column to order by. It is important
+ * to have a unique key constraint on the sort key to guarantee that no data is lost
+ * between executions.
*
* @author Thomas Risberg
* @author Dave Syer
diff --git a/src/site/docbook/reference/readersAndWriters.xml b/src/site/docbook/reference/readersAndWriters.xml
index 1df2bd29c..436485040 100644
--- a/src/site/docbook/reference/readersAndWriters.xml
+++ b/src/site/docbook/reference/readersAndWriters.xml
@@ -2192,6 +2192,9 @@ itemReader.close(executionContext);
also provide an optional where clause. These clauses will be used to
build an SQL statement combined with the required sortKey.
+