A message handler that executes Stored Procedures for update purposes.
Stored procedure parameter value are by default automatically extracted from
the Payload if the payload's bean properties match the parameters of the Stored
Procedure.
This may be sufficient for basic use cases. For more sophisticated options
consider passing in one or more ProcedureParameter.
If you need to handle the return parameters of the called stored procedure
explicitly, please consider using a StoredProcOutboundGateway instead.
Also, if you need to execute SQL Functions, please also use the
StoredProcOutboundGateway. As functions are typically used to look up
values, only, the Stored Procedure message handler does purposefully not support
SQL function calls. If you believe there are valid use-cases for that, please file a
feature request at http://jira.springsource.org.

Since:

2.1

Author:

Gunnar Hillert

Constructor Summary

StoredProcExecutor(javax.sql.DataSource dataSource,
java.lang.String storedProcedureName)
Constructor taking DataSource from which the DB Connection can be
obtained and the select query to execute the stored procedure.

setFunction(boolean isFunction)
Indicates whether a Stored Procedure or a Function is being executed.

void

setIgnoreColumnMetaData(boolean ignoreColumnMetaData)
For fully supported databases, the underlying SimpleJdbcCall can
retrieve the parameter information for the to be invoked Stored Procedure
from the JDBC Meta-data.

setReturningResultSetRowMappers(java.util.Map<java.lang.String,org.springframework.jdbc.core.RowMapper<?>> returningResultSetRowMappers)
If the Stored Procedure returns ResultSets you may provide a map of
RowMapper to convert the ResultSet to meaningful objects.

void

setReturnValueRequired(boolean returnValueRequired)
Indicates the procedure's return value should be included in the results
returned.

void

setSkipUndeclaredResults(boolean skipUndeclaredResults)
If this variable is set to true then all results from a stored
procedure call that don't have a corresponding SqlOutParameter
declaration will be bypassed.

void

setSqlParameters(java.util.List<org.springframework.jdbc.core.SqlParameter> sqlParameters)
If you database system is not fully supported by Spring and thus obtaining
parameter definitions from the JDBC Meta-data is not possible, you must define
the SqlParameter explicitly.

setIgnoreColumnMetaData

public void setIgnoreColumnMetaData(boolean ignoreColumnMetaData)

For fully supported databases, the underlying SimpleJdbcCall can
retrieve the parameter information for the to be invoked Stored Procedure
from the JDBC Meta-data. However, if the used database does not support
meta data lookups or if you like to provide customized parameter definitions,
this flag can be set to 'true'. It defaults to 'false'.

setUsePayloadAsParameterSource

If set to 'true', the payload of the Message will be used as a source for
providing parameters. If false the entire Message will be available as a
source for parameters.
If no ProcedureParameter are passed in, this property will default to
'true'. This means that using a default BeanPropertySqlParameterSourceFactory
the bean properties of the payload will be used as a source for parameter values for
the to-be-executed Stored Procedure or Function.
However, if ProcedureParameter are passed in, then this property
will by default evaluate to 'false'. ProcedureParameter allow for
SpEl Expressions to be provided and therefore it is highly beneficial to
have access to the entire Message.

Parameters:

usePayloadAsParameterSource - If false the entire Message is used as parameter source.

setFunction

public void setFunction(boolean isFunction)

Indicates whether a Stored Procedure or a Function is being executed.
The default value is false.

Parameters:

isFunction - If set to true an Sql Function is executed rather than a Stored Procedure.

setReturnValueRequired

public void setReturnValueRequired(boolean returnValueRequired)

Indicates the procedure's return value should be included in the results
returned.

Parameters:

returnValueRequired -

setSkipUndeclaredResults

public void setSkipUndeclaredResults(boolean skipUndeclaredResults)

If this variable is set to true then all results from a stored
procedure call that don't have a corresponding SqlOutParameter
declaration will be bypassed.
E.g. Stored Procedures may return an update count value, even though your
Stored Procedure only declared a single result parameter. The exact behavior
depends on the used database.
The value is set on the underlying JdbcTemplate.
Only few developers will probably ever like to process update counts, thus
the value defaults to true.