Top Description Constructors Methods
org.springframework.jdbc.object

public abstract Class StoredProcedure

extends SqlCall
Class Inheritance
Known Direct Subclasses
org.springframework.jdbc.object.GenericStoredProcedure
Imports
java.util.HashMap, .Map, javax.sql.DataSource, org.springframework.dao.DataAccessException, .InvalidDataAccessApiUsageException, org.springframework.jdbc.core.JdbcTemplate, .ParameterMapper, .SqlParameter

Superclass for object abstractions of RDBMS stored procedures. This class is abstract and it is intended that subclasses will provide a typed method for invocation that delegates to the supplied execute method.

The inherited sql property is the name of the stored procedure in the RDBMS.

Authors
Rod Johnson, Thomas Risberg

Constructor Summary

AccessConstructor and Description
protected
StoredProcedure()

Allow use as a bean.

protected
StoredProcedure(DataSource
the DataSource to use throughout the lifetime of this object to obtain connections
ds
,
String
the name of the stored procedure in the database
name
)

Create a new object wrapper for a stored procedure.

protected
StoredProcedure(JdbcTemplate
the JdbcTemplate which wraps DataSource
jdbcTemplate
,
String
the name of the stored procedure in the database
name
)

Create a new object wrapper for a stored procedure.

Method Summary

Modifier and TypeMethod and Description
protected boolean
allowsUnusedParameters()

Overrides org.springframework.jdbc.object.RdbmsOperation.allowsUnusedParameters.

StoredProcedure parameter Maps are by default allowed to contain additional entries that are not actually used as parameters.

public void
declareParameter(SqlParameter
the parameter object
param
)

Overrides org.springframework.jdbc.object.RdbmsOperation.declareParameter.

Declare a parameter.

public Map<String, Object>

Returns:

map of output params, keyed by name as in parameter declarations. Output parameters will appear here, with their values after the stored procedure has been called.
execute
(Object...
variable number of input parameters. Output parameters should not be included in this map. It is legal for values to be null, and this will produce the correct behavior using a NULL argument to the stored procedure.
inParams
)

Execute the stored procedure with the provided parameter values.

public Map<String, Object>

Returns:

map of output params, keyed by name as in parameter declarations. Output parameters will appear here, with their values after the stored procedure has been called.
execute
(Map<String, ?>
map of input parameters, keyed by name as in parameter declarations. Output parameters need not (but can) be included in this map. It is legal for map entries to be null, and this will produce the correct behavior using a NULL argument to the stored procedure.
inParams
)

Execute the stored procedure.

public Map<String, Object>

Returns:

map of output params, keyed by name as in parameter declarations. Output parameters will appear here, with their values after the stored procedure has been called.
execute
(ParameterMapper
map of input parameters, keyed by name as in parameter declarations. Output parameters need not (but can) be included in this map. It is legal for map entries to be null, and this will produce the correct behavior using a NULL argument to the stored procedure.
inParamMapper
)

Execute the stored procedure.

Inherited from org.springframework.jdbc.object.SqlCall:
compileInternalgetCallStringisFunctionisSqlReadyForUsenewCallableStatementCreatornewCallableStatementCreatoronCompileInternalsetFunctionsetSqlReadyForUse

Constructor Detail

StoredProcedureback to summary
protected StoredProcedure()

Allow use as a bean.

StoredProcedureback to summary
protected StoredProcedure(DataSource ds, String name)

Create a new object wrapper for a stored procedure.

Parameters
ds:DataSource

the DataSource to use throughout the lifetime of this object to obtain connections

name:String

the name of the stored procedure in the database

StoredProcedureback to summary
protected StoredProcedure(JdbcTemplate jdbcTemplate, String name)

Create a new object wrapper for a stored procedure.

Parameters
jdbcTemplate:JdbcTemplate

the JdbcTemplate which wraps DataSource

name:String

the name of the stored procedure in the database

Method Detail

allowsUnusedParametersback to summary
protected boolean allowsUnusedParameters()

Overrides org.springframework.jdbc.object.RdbmsOperation.allowsUnusedParameters.

StoredProcedure parameter Maps are by default allowed to contain additional entries that are not actually used as parameters.

Annotations
@Override
declareParameterback to summary
public void declareParameter(SqlParameter param) throws InvalidDataAccessApiUsageException

Overrides org.springframework.jdbc.object.RdbmsOperation.declareParameter.

Declare a parameter.

Parameters declared as SqlParameter and SqlInOutParameter will always be used to provide input values. In addition to this, any parameter declared as SqlOutParameter where a non-null input value is provided will also be used as an input parameter.

Note

Calls to declareParameter must be made in the same order as they appear in the database's stored procedure parameter list.

Names are purely used to help mapping.

Parameters
param:SqlParameter

the parameter object

Annotations
@Override
Exceptions
InvalidDataAccessApiUsageException:
if the parameter has no name, or if the operation is already compiled, and hence cannot be configured further
executeback to summary
public Map<String, Object> execute(Object... inParams)

Execute the stored procedure with the provided parameter values. This is a convenience method where the order of the passed in parameter values must match the order that the parameters where declared in.

Parameters
inParams:Object[]

variable number of input parameters. Output parameters should not be included in this map. It is legal for values to be null, and this will produce the correct behavior using a NULL argument to the stored procedure.

Returns:Map<String, Object>

map of output params, keyed by name as in parameter declarations. Output parameters will appear here, with their values after the stored procedure has been called.

executeback to summary
public Map<String, Object> execute(Map<String, ?> inParams) throws DataAccessException

Execute the stored procedure. Subclasses should define a strongly typed execute method (with a meaningful name) that invokes this method, populating the input map and extracting typed values from the output map. Subclass execute methods will often take domain objects as arguments and return values. Alternatively, they can return void.

Parameters
inParams:Map<String, ?>

map of input parameters, keyed by name as in parameter declarations. Output parameters need not (but can) be included in this map. It is legal for map entries to be null, and this will produce the correct behavior using a NULL argument to the stored procedure.

Returns:Map<String, Object>

map of output params, keyed by name as in parameter declarations. Output parameters will appear here, with their values after the stored procedure has been called.

executeback to summary
public Map<String, Object> execute(ParameterMapper inParamMapper) throws DataAccessException

Execute the stored procedure. Subclasses should define a strongly typed execute method (with a meaningful name) that invokes this method, passing in a ParameterMapper that will populate the input map. This allows mapping database specific features since the ParameterMapper has access to the Connection object. The execute method is also responsible for extracting typed values from the output map. Subclass execute methods will often take domain objects as arguments and return values. Alternatively, they can return void.

Parameters
inParamMapper:ParameterMapper

map of input parameters, keyed by name as in parameter declarations. Output parameters need not (but can) be included in this map. It is legal for map entries to be null, and this will produce the correct behavior using a NULL argument to the stored procedure.

Returns:Map<String, Object>

map of output params, keyed by name as in parameter declarations. Output parameters will appear here, with their values after the stored procedure has been called.