Class StoredProcedureItemReaderBuilder<T>
java.lang.Object
org.springframework.batch.item.database.builder.StoredProcedureItemReaderBuilder<T>
A fluent builder API for the configuration of a
StoredProcedureItemReader
.- Since:
- 4.0.0
- Author:
- Michael Minella, Mahmoud Ben Hassine, Drummond Dawson
- See Also:
-
Field Summary
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionbuild()
Validates configuration and builds a new reader instancecurrentItemCount
(int currentItemCount) Index for the current item.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.function()
Indicates the stored procedure is a functionignoreWarnings
(boolean ignoreWarnings) Indicates if SQL warnings should be ignored or if an 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
.parameters
(org.springframework.jdbc.core.SqlParameter... parameters) SQL parameters to be set when executing the stored procedurepreparedStatementSetter
(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.procedureName
(String procedureName) The name of the stored procedure to executequeryTimeout
(int queryTimeout) The time in milliseconds for the query to timeoutrefCursorPosition
(int refCursorPosition) The parameter position of the REF CURSOR.TheRowMapper
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.useSharedExtendedConnection
(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
.
-
Field Details
-
VALUE_NOT_SET
public static final int VALUE_NOT_SET- See Also:
-
-
Constructor Details
-
StoredProcedureItemReaderBuilder
public StoredProcedureItemReaderBuilder()
-
-
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
Indicates if SQL warnings should be ignored or if an exception should be thrown.- Parameters:
ignoreWarnings
- indicator. Defaults to true- Returns:
- this instance for method chaining
- See Also:
-
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 StoredProcedureItemReaderBuilder<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:
-
rowMapper
public StoredProcedureItemReaderBuilder<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:
-
procedureName
The name of the stored procedure to execute- Parameters:
procedureName
- name of the procedure- Returns:
- this instance for method chaining
- See Also:
-
parameters
public StoredProcedureItemReaderBuilder<T> parameters(org.springframework.jdbc.core.SqlParameter... parameters) SQL parameters to be set when executing the stored procedure- Parameters:
parameters
- parameters to be set- Returns:
- this instance for method chaining
- See Also:
-
function
Indicates the stored procedure is a function- Returns:
- this instance for method chaining
- See Also:
-
refCursorPosition
The parameter position of the REF CURSOR. Only used for Oracle and PostgreSQL that use REF CURSORs. For any other database, this should remain as the default (0).- Parameters:
refCursorPosition
- the parameter position- Returns:
- this instance for method chaining
- See Also:
-
build
Validates configuration and builds a new reader instance- Returns:
- a fully constructed
StoredProcedureItemReader
-