类 StoredProcedureItemReader<T>
- java.lang.Object
- org.springframework.batch.item.ItemStreamSupport
- org.springframework.batch.item.support.AbstractItemStreamItemReader<T>
- org.springframework.batch.item.support.AbstractItemCountingItemStreamItemReader<T>
- org.springframework.batch.item.database.AbstractCursorItemReader<T>
- org.springframework.batch.item.database.StoredProcedureItemReader<T>
- 所有已实现的接口:
ItemReader<T>
,ItemStream
,ItemStreamReader<T>
,org.springframework.beans.factory.InitializingBean
public class StoredProcedureItemReader<T> extends AbstractCursorItemReader<T>
Item reader implementation that executes a stored procedure and then reads the returned cursor and continually retrieves the next row in the
ResultSet
.The callable statement used to open the cursor is created with the 'READ_ONLY' option as well as with the 'TYPE_FORWARD_ONLY' option. By default the cursor will be opened using a separate connection which means that it will not participate in any transactions created as part of the step processing.
Each call to
AbstractItemCountingItemStreamItemReader.read()
will call the provided RowMapper, passing in the ResultSet.This class is modeled after the similar
JdbcCursorItemReader
class.- 作者:
- Thomas Risberg
字段概要
从类继承的字段 org.springframework.batch.item.database.AbstractCursorItemReader
log, rs, VALUE_NOT_SET
构造器概要
构造器 构造器 说明 StoredProcedureItemReader()
方法概要
所有方法 实例方法 具体方法 修饰符和类型 方法 说明 void
afterPropertiesSet()
Assert that mandatory properties are set.protected void
cleanupOnClose()
Close the cursor and database connection.java.lang.String
getSql()
protected void
openCursor(java.sql.Connection con)
protected T
readCursor(java.sql.ResultSet rs, int currentRow)
Read the cursor and map to the type of object this reader should return.void
setFunction(boolean function)
Set whether this stored procedure is a function.void
setParameters(org.springframework.jdbc.core.SqlParameter[] parameters)
Add one or more declared parameters.void
setPreparedStatementSetter(org.springframework.jdbc.core.PreparedStatementSetter preparedStatementSetter)
Set the PreparedStatementSetter to use if any parameter values that need to be set in the supplied query.void
setProcedureName(java.lang.String sprocedureName)
Set the SQL statement to be used when creating the cursor.void
setRefCursorPosition(int refCursorPosition)
Set the parameter position of the REF CURSOR.void
setRowMapper(org.springframework.jdbc.core.RowMapper<T> rowMapper)
Set the RowMapper to be used for all calls to read().从类继承的方法 org.springframework.batch.item.database.AbstractCursorItemReader
applyStatementSettings, doClose, doOpen, doRead, getDataSource, getExceptionTranslator, handleWarnings, initializeConnection, isUseSharedExtendedConnection, jumpToItem, setConnectionAutoCommit, setDataSource, setDriverSupportsAbsolute, setFetchSize, setIgnoreWarnings, setMaxRows, setQueryTimeout, setUseSharedExtendedConnection, setVerifyCursorPosition
从类继承的方法 org.springframework.batch.item.support.AbstractItemCountingItemStreamItemReader
close, getCurrentItemCount, isSaveState, open, read, setCurrentItemCount, setMaxItemCount, setSaveState, update
从类继承的方法 org.springframework.batch.item.ItemStreamSupport
getExecutionContextKey, setExecutionContextName, setName
构造器详细资料
StoredProcedureItemReader
public StoredProcedureItemReader()
方法详细资料
setRowMapper
public void setRowMapper(org.springframework.jdbc.core.RowMapper<T> rowMapper)
Set the RowMapper to be used for all calls to read().- 参数:
rowMapper
- the RowMapper to use to map the results
setProcedureName
public void setProcedureName(java.lang.String sprocedureName)
Set the SQL statement to be used when creating the cursor. This statement should be a complete and valid SQL statement, as it will be run directly without any modification.- 参数:
sprocedureName
- the SQL used to call the statement
setPreparedStatementSetter
public void setPreparedStatementSetter(org.springframework.jdbc.core.PreparedStatementSetter preparedStatementSetter)
Set the PreparedStatementSetter to use if any parameter values that need to be set in the supplied query.- 参数:
preparedStatementSetter
- used to populate the SQL
setParameters
public void setParameters(org.springframework.jdbc.core.SqlParameter[] parameters)
Add one or more declared parameters. Used for configuring this operation when used in a bean factory. Each parameter will specify SQL type and (optionally) the parameter's name.- 参数:
parameters
- Array containing the declaredSqlParameter
objects
setFunction
public void setFunction(boolean function)
Set whether this stored procedure is a function.- 参数:
function
- indicator
setRefCursorPosition
public void setRefCursorPosition(int refCursorPosition)
Set the parameter position of the REF CURSOR. Only used for Oracle and PostgreSQL that use REF CURSORs. For any other database this should be kept as 0 which is the default.- 参数:
refCursorPosition
- The parameter position of the REF CURSOR
afterPropertiesSet
public void afterPropertiesSet() throws java.lang.Exception
Assert that mandatory properties are set.- 指定者:
afterPropertiesSet
在接口中org.springframework.beans.factory.InitializingBean
- 覆盖:
afterPropertiesSet
在类中AbstractCursorItemReader<T>
- 抛出:
java.lang.IllegalArgumentException
- if either data source or SQL properties not set.java.lang.Exception
openCursor
protected void openCursor(java.sql.Connection con)
- 指定者:
openCursor
在类中AbstractCursorItemReader<T>
readCursor
protected T readCursor(java.sql.ResultSet rs, int currentRow) throws java.sql.SQLException
从类复制的说明:AbstractCursorItemReader
Read the cursor and map to the type of object this reader should return. This method must be overridden by subclasses.- 指定者:
readCursor
在类中AbstractCursorItemReader<T>
- 参数:
rs
- The current result setcurrentRow
- Current position of the result set- 返回:
- the mapped object at the cursor position
- 抛出:
java.sql.SQLException
- if interactions with the current result set fail
cleanupOnClose
protected void cleanupOnClose() throws java.lang.Exception
Close the cursor and database connection.- 指定者:
cleanupOnClose
在类中AbstractCursorItemReader<T>
- 抛出:
java.lang.Exception
getSql
public java.lang.String getSql()
- 指定者:
getSql
在类中AbstractCursorItemReader<T>