Class StoredProcedureItemReaderBuilder<T>
- java.lang.Object
- org.springframework.batch.item.database.builder.StoredProcedureItemReaderBuilder<T>
public class StoredProcedureItemReaderBuilder<T> extends java.lang.ObjectA fluent builder API for the configuration of aStoredProcedureItemReader.- Since:
- 4.0.0
- Author:
- Michael Minella, Mahmoud Ben Hassine
- See Also:
StoredProcedureItemReader
Field Summary
Fields Modifier and Type Field Description static intVALUE_NOT_SET
Constructor Summary
Constructors Constructor Description StoredProcedureItemReaderBuilder()
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description StoredProcedureItemReader<T>build()Validates configuration and builds a new reader instanceStoredProcedureItemReaderBuilder<T>currentItemCount(int currentItemCount)Index for the current item.StoredProcedureItemReaderBuilder<T>dataSource(javax.sql.DataSource dataSource)TheDataSourceto read fromStoredProcedureItemReaderBuilder<T>driverSupportsAbsolute(boolean driverSupportsAbsolute)Indicates if the JDBC driver supports setting the absolute row on theResultSet.StoredProcedureItemReaderBuilder<T>fetchSize(int fetchSize)A hint to the driver as to how many rows to return with each fetch.StoredProcedureItemReaderBuilder<T>function()Indicates the stored procedure is a functionStoredProcedureItemReaderBuilder<T>ignoreWarnings(boolean ignoreWarnings)Indicates if SQL warnings should be ignored or if an exception should be thrown.StoredProcedureItemReaderBuilder<T>maxItemCount(int maxItemCount)Configure the max number of items to be read.StoredProcedureItemReaderBuilder<T>maxRows(int maxRows)The max number of rows theResultSetcan containStoredProcedureItemReaderBuilder<T>name(java.lang.String name)The name used to calculate the key within theExecutionContext.StoredProcedureItemReaderBuilder<T>parameters(org.springframework.jdbc.core.SqlParameter[] parameters)SQL parameters to be set when executing the stored procedureStoredProcedureItemReaderBuilder<T>preparedStatementSetter(org.springframework.jdbc.core.PreparedStatementSetter preparedStatementSetter)Configures the providedPreparedStatementSetterto be used to populate any arguments in the SQL query to be executed for the reader.StoredProcedureItemReaderBuilder<T>procedureName(java.lang.String procedureName)The name of the stored procedure to executeStoredProcedureItemReaderBuilder<T>queryTimeout(int queryTimeout)The time in milliseconds for the query to timeoutStoredProcedureItemReaderBuilder<T>refCursorPosition(int refCursorPosition)The parameter position of the REF CURSOR.StoredProcedureItemReaderBuilder<T>rowMapper(org.springframework.jdbc.core.RowMapper<T> rowMapper)TheRowMapperused to map the results of the cursor to each item.StoredProcedureItemReaderBuilder<T>saveState(boolean saveState)Configure if the state of theItemStreamSupportshould be persisted within theExecutionContextfor restart purposes.StoredProcedureItemReaderBuilder<T>useSharedExtendedConnection(boolean useSharedExtendedConnection)Indicates that the connection used for the cursor is being used by all other processing, therefor part of the same transaction.StoredProcedureItemReaderBuilder<T>verifyCursorPosition(boolean verifyCursorPosition)Indicates if the reader should verify the current position of theResultSetafter being passed to theRowMapper.
Field Detail
VALUE_NOT_SET
public static final int VALUE_NOT_SET
- See Also:
- Constant Field Values
Method Detail
saveState
public StoredProcedureItemReaderBuilder<T> saveState(boolean saveState)
Configure if the state of theItemStreamSupportshould be persisted within theExecutionContextfor restart purposes.- Parameters:
saveState- defaults to true- Returns:
- The current instance of the builder.
name
public StoredProcedureItemReaderBuilder<T> name(java.lang.String 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:
ItemStreamSupport.setName(String)
maxItemCount
public StoredProcedureItemReaderBuilder<T> maxItemCount(int 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:
AbstractItemCountingItemStreamItemReader.setMaxItemCount(int)
currentItemCount
public StoredProcedureItemReaderBuilder<T> currentItemCount(int 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:
AbstractItemCountingItemStreamItemReader.setCurrentItemCount(int)
dataSource
public StoredProcedureItemReaderBuilder<T> dataSource(javax.sql.DataSource dataSource)
TheDataSourceto read from- Parameters:
dataSource- a relational data base- Returns:
- this instance for method chaining
- See Also:
AbstractCursorItemReader.setDataSource(DataSource)
fetchSize
public StoredProcedureItemReaderBuilder<T> fetchSize(int 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:
AbstractCursorItemReader.setFetchSize(int)
maxRows
public StoredProcedureItemReaderBuilder<T> maxRows(int maxRows)
The max number of rows theResultSetcan contain- Parameters:
maxRows- the max- Returns:
- this instance for method chaining
- See Also:
AbstractCursorItemReader.setMaxRows(int)
queryTimeout
public StoredProcedureItemReaderBuilder<T> queryTimeout(int queryTimeout)
The time in milliseconds for the query to timeout- Parameters:
queryTimeout- timeout- Returns:
- this instance for method chaining
- See Also:
AbstractCursorItemReader.setQueryTimeout(int)
ignoreWarnings
public StoredProcedureItemReaderBuilder<T> ignoreWarnings(boolean 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:
AbstractCursorItemReader.setIgnoreWarnings(boolean)
verifyCursorPosition
public StoredProcedureItemReaderBuilder<T> verifyCursorPosition(boolean verifyCursorPosition)
Indicates if the reader should verify the current position of theResultSetafter being passed to theRowMapper. Defaults to true.- Parameters:
verifyCursorPosition- indicator- Returns:
- this instance for method chaining
- See Also:
AbstractCursorItemReader.setVerifyCursorPosition(boolean)
driverSupportsAbsolute
public StoredProcedureItemReaderBuilder<T> driverSupportsAbsolute(boolean driverSupportsAbsolute)
Indicates if the JDBC driver supports setting the absolute row on theResultSet.- Parameters:
driverSupportsAbsolute- indicator- Returns:
- this instance for method chaining
- See Also:
AbstractCursorItemReader.setDriverSupportsAbsolute(boolean)
useSharedExtendedConnection
public StoredProcedureItemReaderBuilder<T> useSharedExtendedConnection(boolean useSharedExtendedConnection)
Indicates that the connection used for the cursor is being used by all other processing, therefor part of the same transaction.- Parameters:
useSharedExtendedConnection- indicator- Returns:
- this instance for method chaining
- See Also:
AbstractCursorItemReader.setUseSharedExtendedConnection(boolean)
preparedStatementSetter
public StoredProcedureItemReaderBuilder<T> preparedStatementSetter(org.springframework.jdbc.core.PreparedStatementSetter preparedStatementSetter)
Configures the providedPreparedStatementSetterto 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:
StoredProcedureItemReader.setPreparedStatementSetter(PreparedStatementSetter)
rowMapper
public StoredProcedureItemReaderBuilder<T> rowMapper(org.springframework.jdbc.core.RowMapper<T> rowMapper)
TheRowMapperused to map the results of the cursor to each item.- Parameters:
rowMapper-RowMapper- Returns:
- this instance for method chaining
- See Also:
StoredProcedureItemReader.setRowMapper(RowMapper)
procedureName
public StoredProcedureItemReaderBuilder<T> procedureName(java.lang.String procedureName)
The name of the stored procedure to execute- Parameters:
procedureName- name of the procedure- Returns:
- this instance for method chaining
- See Also:
StoredProcedureItemReader.setProcedureName(String)
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:
StoredProcedureItemReader.setParameters(SqlParameter[])
function
public StoredProcedureItemReaderBuilder<T> function()
Indicates the stored procedure is a function- Returns:
- this instance for method chaining
- See Also:
StoredProcedureItemReader.setFunction(boolean)
refCursorPosition
public StoredProcedureItemReaderBuilder<T> refCursorPosition(int 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:
StoredProcedureItemReader.setRefCursorPosition(int)
build
public StoredProcedureItemReader<T> build()
Validates configuration and builds a new reader instance- Returns:
- a fully constructed
StoredProcedureItemReader