Class JdbcCursorItemReaderBuilder<T>
java.lang.Object
org.springframework.batch.item.database.builder.JdbcCursorItemReaderBuilder<T>
Builder for the
JdbcCursorItemReader
- Since:
- 4.0
- Author:
- Michael Minella, Glenn Renfro, Drummond Dawson, Mahmoud Ben Hassine, Ankur Trapasiya, Parikshit Dutta, Fabio Molignoni, Juyoung Kim
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionbeanRowMapper
(Class<T> mappedClass) Creates aBeanPropertyRowMapper
to be used as yourRowMapper
.build()
Validates configuration and builds a new reader instance.connectionAutoCommit
(boolean connectionAutoCommit) Set whether "autoCommit" should be overridden for the connection used by the cursor.currentItemCount
(int currentItemCount) Index for the current item.dataRowMapper
(Class<T> mappedClass) Creates aDataClassRowMapper
to be used as yourRowMapper
.dataSource
(DataSource dataSource) TheDataSource
to read fromdriverSupportsAbsolute
(boolean driverSupportsAbsolute) Indicates if the JDBC driver supports setting the absolute row on theResultSet
.fetchSize
(int fetchSize) A hint to the driver as to how many rows to return with each fetch.ignoreWarnings
(boolean ignoreWarnings) Set whether SQLWarnings should be ignored (only logged) or exception should be thrown.maxItemCount
(int maxItemCount) Configure the max number of items to be read.maxRows
(int maxRows) The max number of rows theResultSet
can containThe name used to calculate the key within theExecutionContext
.preparedStatementSetter
(org.springframework.jdbc.core.PreparedStatementSetter preparedStatementSetter) Configures the providedPreparedStatementSetter
to be used to populate any arguments in the SQL query to be executed for the reader.queryArguments
(Object... args) Configures aPreparedStatementSetter
that will use the array as the values to be set on the query to be executed for this reader.queryArguments
(Object[] args, int[] types) Configures aPreparedStatementSetter
that will use the Object [] as the values to be set on the query to be executed for this reader.queryArguments
(List<?> args) Configures aPreparedStatementSetter
that will use the List as the values to be set on the query to be executed for this reader.queryTimeout
(int queryTimeout) The time in milliseconds for the query to timeoutTheRowMapper
used to map the results of the cursor to each item.saveState
(boolean saveState) Configure if the state of theItemStreamSupport
should be persisted within theExecutionContext
for restart purposes.The query to be executed for this readeruseSharedExtendedConnection
(boolean useSharedExtendedConnection) Indicates that the connection used for the cursor is being used by all other processing, therefor part of the same transaction.verifyCursorPosition
(boolean verifyCursorPosition) Indicates if the reader should verify the current position of theResultSet
after being passed to theRowMapper
.
-
Constructor Details
-
JdbcCursorItemReaderBuilder
public JdbcCursorItemReaderBuilder()
-
-
Method Details
-
saveState
Configure if the state of theItemStreamSupport
should be persisted within theExecutionContext
for restart purposes.- Parameters:
saveState
- defaults to true- Returns:
- The current instance of the builder.
-
name
The name used to calculate the key within theExecutionContext
. Required ifsaveState(boolean)
is set to true.- Parameters:
name
- name of the reader instance- Returns:
- The current instance of the builder.
- See Also:
-
maxItemCount
Configure the max number of items to be read.- Parameters:
maxItemCount
- the max items to be read- Returns:
- The current instance of the builder.
- See Also:
-
currentItemCount
Index for the current item. Used on restarts to indicate where to start from.- Parameters:
currentItemCount
- current index- Returns:
- this instance for method chaining
- See Also:
-
dataSource
TheDataSource
to read from- Parameters:
dataSource
- a relational data base- Returns:
- this instance for method chaining
- See Also:
-
fetchSize
A hint to the driver as to how many rows to return with each fetch.- Parameters:
fetchSize
- the hint- Returns:
- this instance for method chaining
- See Also:
-
maxRows
The max number of rows theResultSet
can contain- Parameters:
maxRows
- the max- Returns:
- this instance for method chaining
- See Also:
-
queryTimeout
The time in milliseconds for the query to timeout- Parameters:
queryTimeout
- timeout- Returns:
- this instance for method chaining
- See Also:
-
ignoreWarnings
Set whether SQLWarnings should be ignored (only logged) or exception should be thrown. Defaults totrue
.- Parameters:
ignoreWarnings
- iftrue
, warnings are ignored
-
verifyCursorPosition
Indicates if the reader should verify the current position of theResultSet
after being passed to theRowMapper
. Defaults to true.- Parameters:
verifyCursorPosition
- indicator- Returns:
- this instance for method chaining
- See Also:
-
driverSupportsAbsolute
Indicates if the JDBC driver supports setting the absolute row on theResultSet
.- Parameters:
driverSupportsAbsolute
- indicator- Returns:
- this instance for method chaining
- See Also:
-
preparedStatementSetter
public JdbcCursorItemReaderBuilder<T> preparedStatementSetter(org.springframework.jdbc.core.PreparedStatementSetter preparedStatementSetter) Configures the providedPreparedStatementSetter
to be used to populate any arguments in the SQL query to be executed for the reader.- Parameters:
preparedStatementSetter
- setter- Returns:
- this instance for method chaining
- See Also:
-
queryArguments
Configures aPreparedStatementSetter
that will use the array as the values to be set on the query to be executed for this reader.- Parameters:
args
- values to set on the reader query- Returns:
- this instance for method chaining
-
queryArguments
Configures aPreparedStatementSetter
that will use the Object [] as the values to be set on the query to be executed for this reader. The int[] will provide the types (Types
) for each of the values provided.- Parameters:
args
- values to set on the querytypes
- the type for each value in the args array- Returns:
- this instance for method chaining
-
queryArguments
Configures aPreparedStatementSetter
that will use the List as the values to be set on the query to be executed for this reader.- Parameters:
args
- values to set on the query- Returns:
- this instance for method chaining
-
sql
The query to be executed for this reader- Parameters:
sql
- query- Returns:
- this instance for method chaining
- See Also:
-
rowMapper
public JdbcCursorItemReaderBuilder<T> rowMapper(org.springframework.jdbc.core.RowMapper<T> rowMapper) TheRowMapper
used to map the results of the cursor to each item.- Parameters:
rowMapper
-RowMapper
- Returns:
- this instance for method chaining
- See Also:
-
beanRowMapper
Creates aBeanPropertyRowMapper
to be used as yourRowMapper
.- Parameters:
mappedClass
- the class for the row mapper- Returns:
- this instance for method chaining
- See Also:
-
BeanPropertyRowMapper
-
dataRowMapper
Creates aDataClassRowMapper
to be used as yourRowMapper
.- Parameters:
mappedClass
- the class for the row mapper- Returns:
- this instance for method chaining
- Since:
- 5.2
- See Also:
-
DataClassRowMapper
-
connectionAutoCommit
Set whether "autoCommit" should be overridden for the connection used by the cursor. If not set, defaults to Connection / Datasource default configuration.- Parameters:
connectionAutoCommit
- value to set on underlying JDBC connection- Returns:
- this instance for method chaining
- See Also:
-
build
Validates configuration and builds a new reader instance.- Returns:
- a fully constructed
JdbcCursorItemReader
-