org.springframework.jdbc.object
Class StoredProcedure

java.lang.Object
  extended byorg.springframework.jdbc.object.RdbmsOperation
      extended byorg.springframework.jdbc.object.SqlCall
          extended byorg.springframework.jdbc.object.StoredProcedure
All Implemented Interfaces:
InitializingBean

public abstract class StoredProcedure
extends SqlCall

Superclass for object abstractions of RDBMS stored procedures. This class is abstract and its execute methods are protected, preventing use other than through a subclass that offers tighter typing.

The inherited sql property is the name of the stored procedure in the RDBMS. Note that JDBC 3.0 introduces named parameters, although the other features provided by this class are still necessary in JDBC 3.0.

Version:
$Id: StoredProcedure.java,v 1.10 2004/03/18 02:46:13 trisberg Exp $
Author:
Rod Johnson, Thomas Risberg

Field Summary
 
Fields inherited from class org.springframework.jdbc.object.RdbmsOperation
logger
 
Constructor Summary
protected StoredProcedure()
          Allow use as a bean.
protected StoredProcedure(javax.sql.DataSource ds, java.lang.String name)
          Create a new object wrapper for a stored procedure.
protected StoredProcedure(JdbcTemplate jdbcTemplate, java.lang.String name)
          Create a new object wrapper for a stored procedure.
 
Method Summary
 void declareParameter(SqlParameter p)
          Overridden method.
 java.util.Map execute(java.util.Map inParams)
          Execute the stored procedure.
 java.util.Map execute(ParameterMapper inParamMapper)
          Execute the stored procedure.
 
Methods inherited from class org.springframework.jdbc.object.SqlCall
compileInternal, getCallString, isFunction, newCallableStatementCreator, newCallableStatementCreator, onCompileInternal, setFunction
 
Methods inherited from class org.springframework.jdbc.object.RdbmsOperation
afterPropertiesSet, compile, getDeclaredParameters, getJdbcTemplate, getSql, isCompiled, setDataSource, setJdbcTemplate, setSql, setTypes, validateParameters
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

StoredProcedure

protected StoredProcedure()
Allow use as a bean.


StoredProcedure

protected StoredProcedure(javax.sql.DataSource ds,
                          java.lang.String name)
Create a new object wrapper for a stored procedure.

Parameters:
ds - DataSource to use throughout the lifetime of this object to obtain connections
name - name of the stored procedure in the database.

StoredProcedure

protected StoredProcedure(JdbcTemplate jdbcTemplate,
                          java.lang.String name)
Create a new object wrapper for a stored procedure.

Parameters:
jdbcTemplate - JdbcTemplate which wraps DataSource
name - name of the stored procedure in the database.
Method Detail

declareParameter

public void declareParameter(SqlParameter p)
                      throws InvalidDataAccessApiUsageException
Overridden method. Add a parameter. NB: Calls to addParameter 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

Overrides:
declareParameter in class RdbmsOperation
Parameters:
p - Parameter object (as defined in the Parameter inner class)
Throws:
InvalidDataAccessApiUsageException - if the operation is already compiled, and hence cannot be configured further

execute

public java.util.Map execute(java.util.Map inParams)
                      throws InvalidDataAccessApiUsageException
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 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 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.
Throws:
InvalidDataAccessApiUsageException

execute

public java.util.Map execute(ParameterMapper inParamMapper)
                      throws InvalidDataAccessApiUsageException
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 - 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 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.
Throws:
InvalidDataAccessApiUsageException


Copyright (C) 2003-2004 The Spring Framework Project.