|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.springframework.batch.item.support.AbstractItemCountingItemStreamItemReader<T> org.springframework.batch.item.database.AbstractCursorItemReader<T> org.springframework.batch.item.database.StoredProcedureItemReader<T>
public class StoredProcedureItemReader<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.
Field Summary |
---|
Fields inherited from class org.springframework.batch.item.database.AbstractCursorItemReader |
---|
log, rs, VALUE_NOT_SET |
Constructor Summary | |
---|---|
StoredProcedureItemReader()
|
Method Summary | |
---|---|
void |
afterPropertiesSet()
Assert that mandatory properties are set. |
protected void |
cleanupOnClose()
Close the cursor and database connection. |
String |
getSql()
|
protected void |
openCursor(Connection con)
|
protected T |
readCursor(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(SqlParameter[] parameters)
Add one or more declared parameters. |
void |
setPreparedStatementSetter(PreparedStatementSetter preparedStatementSetter)
Set the PreparedStatementSetter to use if any parameter values that need to be set in the supplied query. |
void |
setProcedureName(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(RowMapper rowMapper)
Set the RowMapper to be used for all calls to read(). |
Methods inherited from class org.springframework.batch.item.database.AbstractCursorItemReader |
---|
applyStatementSettings, doClose, doOpen, doRead, getDataSource, getExceptionTranslator, handleWarnings, initializeConnection, isUseSharedExtendedConnection, jumpToItem, setDataSource, setDriverSupportsAbsolute, setFetchSize, setIgnoreWarnings, setMaxRows, setQueryTimeout, setUseSharedExtendedConnection, setVerifyCursorPosition |
Methods inherited from class org.springframework.batch.item.support.AbstractItemCountingItemStreamItemReader |
---|
close, getCurrentItemCount, getExecutionContextUserSupport, isSaveState, open, read, setCurrentItemCount, setMaxItemCount, setName, setSaveState, update |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public StoredProcedureItemReader()
Method Detail |
---|
public void setRowMapper(RowMapper rowMapper)
rowMapper
- public void setProcedureName(String sprocedureName)
sprocedureName
- public void setPreparedStatementSetter(PreparedStatementSetter preparedStatementSetter)
preparedStatementSetter
- public void setParameters(SqlParameter[] parameters)
parameters
- Array containing the declared SqlParameter
objectspublic void setFunction(boolean function)
public void setRefCursorPosition(int refCursorPosition)
refCursorPosition
- The parameter position of the REF CURSORpublic void afterPropertiesSet() throws Exception
afterPropertiesSet
in interface InitializingBean
afterPropertiesSet
in class AbstractCursorItemReader<T>
IllegalArgumentException
- if either data source or sql properties
not set.
Exception
protected void openCursor(Connection con)
openCursor
in class AbstractCursorItemReader<T>
protected T readCursor(ResultSet rs, int currentRow) throws SQLException
AbstractCursorItemReader
readCursor
in class AbstractCursorItemReader<T>
rs
- The current result setcurrentRow
- Current position of the result set
SQLException
protected void cleanupOnClose() throws Exception
cleanupOnClose
in class AbstractCursorItemReader<T>
Exception
public String getSql()
getSql
in class AbstractCursorItemReader<T>
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |