Spring Framework

org.springframework.jdbc.core.simple
Class AbstractJdbcCall

java.lang.Object
  extended by org.springframework.jdbc.core.simple.AbstractJdbcCall
Direct Known Subclasses:
SimpleJdbcCall

public abstract class AbstractJdbcCall
extends java.lang.Object

Abstract class to provide base functionality for easy stored procedure calls based on configuration options and database metadata. This class provides the base SPI for SimpleJdbcCall.

Since:
2.5
Author:
Thomas Risberg

Field Summary
protected  org.apache.commons.logging.Log logger
          Logger available to subclasses
 
Constructor Summary
protected AbstractJdbcCall(javax.sql.DataSource dataSource)
          Constructor to be used when initializing using a DataSource.
protected AbstractJdbcCall(JdbcTemplate jdbcTemplate)
          Constructor to be used when initializing using a JdbcTemplate.
 
Method Summary
 void addDeclaredParameter(SqlParameter parameter)
          Add a declared parameter to the list of parameters for the call.
 void addDeclaredRowMapper(java.lang.String parameterName, ParameterizedRowMapper rowMapper)
          Deprecated. in favor of addDeclaredRowMapper(String, org.springframework.jdbc.core.RowMapper)
 void addDeclaredRowMapper(java.lang.String parameterName, RowMapper rowMapper)
          Add a RowMapper for the specified parameter or column.
protected  void checkCompiled()
          Check whether this operation has been compiled already; lazily compile it if not already compiled.
 void compile()
          Compile this JdbcCall using provided parameters and meta data plus other settings.
protected  void compileInternal()
          Method to perform the actual compilation.
protected  java.util.Map<java.lang.String,java.lang.Object> doExecute(java.util.Map<java.lang.String,?> args)
          Method that provides execution of the call using the passed in Map of parameters
protected  java.util.Map<java.lang.String,java.lang.Object> doExecute(java.lang.Object[] args)
          Method that provides execution of the call using the passed in array of parameters
protected  java.util.Map<java.lang.String,java.lang.Object> doExecute(SqlParameterSource parameterSource)
          Method that provides execution of the call using the passed in SqlParameterSource
protected  CallableStatementCreatorFactory getCallableStatementFactory()
          Get the CallableStatementCreatorFactory being used
protected  java.util.List<SqlParameter> getCallParameters()
          Get a List of all the call parameters to be used for call.
 java.lang.String getCallString()
          Get the call string that should be used based on parameters and meta data.
 java.lang.String getCatalogName()
          Get the catalog name used.
 java.util.Set<java.lang.String> getInParameterNames()
          Get the names of in parameters to be used.
 JdbcTemplate getJdbcTemplate()
          Get the configured JdbcTemplate
 java.lang.String getProcedureName()
          Get the name of the stored procedure.
protected  java.lang.String getScalarOutParameterName()
          Get the name of a single out parameter or return value.
 java.lang.String getSchemaName()
          Get the schema name used.
 boolean isCompiled()
          Is this operation "compiled"?
 boolean isFunction()
          Is this call a function call?
 boolean isReturnValueRequired()
          Does the call require a return value?
protected  java.util.Map<java.lang.String,?> matchInParameterValuesWithCallParameters(java.util.Map<java.lang.String,?> args)
          Match the provided in parameter values with registered parameters and parameters defined via metadata processing.
protected  java.util.Map<java.lang.String,java.lang.Object> matchInParameterValuesWithCallParameters(SqlParameterSource parameterSource)
          Match the provided in parameter values with registered parameters and parameters defined via metadata processing.
protected  void onCompileInternal()
          Hook method that subclasses may override to react to compilation.
 void setAccessCallParameterMetaData(boolean accessCallParameterMetaData)
          Specify whether the parameter metadata for the call should be used.
 void setCatalogName(java.lang.String catalogName)
          Set the catalog name to use.
 void setFunction(boolean function)
          Specify whether this call is a function call.
 void setInParameterNames(java.util.Set<java.lang.String> inParameterNames)
          Set the names of in parameters to be used.
 void setProcedureName(java.lang.String procedureName)
          Set the name of the stored procedure.
 void setReturnValueRequired(boolean b)
          Specify whether the call requires a rerurn value.
 void setSchemaName(java.lang.String schemaName)
          Set the schema name to use,
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

logger

protected final org.apache.commons.logging.Log logger
Logger available to subclasses

Constructor Detail

AbstractJdbcCall

protected AbstractJdbcCall(javax.sql.DataSource dataSource)
Constructor to be used when initializing using a DataSource.

Parameters:
dataSource - the DataSource to be used

AbstractJdbcCall

protected AbstractJdbcCall(JdbcTemplate jdbcTemplate)
Constructor to be used when initializing using a JdbcTemplate.

Parameters:
jdbcTemplate - the JdbcTemplate to use
Method Detail

getJdbcTemplate

public JdbcTemplate getJdbcTemplate()
Get the configured JdbcTemplate


getCallableStatementFactory

protected CallableStatementCreatorFactory getCallableStatementFactory()
Get the CallableStatementCreatorFactory being used


setProcedureName

public void setProcedureName(java.lang.String procedureName)
Set the name of the stored procedure.


getProcedureName

public java.lang.String getProcedureName()
Get the name of the stored procedure.


setInParameterNames

public void setInParameterNames(java.util.Set<java.lang.String> inParameterNames)
Set the names of in parameters to be used.


getInParameterNames

public java.util.Set<java.lang.String> getInParameterNames()
Get the names of in parameters to be used.


setCatalogName

public void setCatalogName(java.lang.String catalogName)
Set the catalog name to use.


getCatalogName

public java.lang.String getCatalogName()
Get the catalog name used.


setSchemaName

public void setSchemaName(java.lang.String schemaName)
Set the schema name to use,


getSchemaName

public java.lang.String getSchemaName()
Get the schema name used.


setFunction

public void setFunction(boolean function)
Specify whether this call is a function call.


isFunction

public boolean isFunction()
Is this call a function call?


setReturnValueRequired

public void setReturnValueRequired(boolean b)
Specify whether the call requires a rerurn value.


isReturnValueRequired

public boolean isReturnValueRequired()
Does the call require a return value?


addDeclaredParameter

public void addDeclaredParameter(SqlParameter parameter)
Add a declared parameter to the list of parameters for the call. Only parameters declared as SqlParameter and SqlInOutParameter will be used to provide input values. This is different from the StoredProcedure class which for backwards compatibility reasons allows input values to be provided for parameters declared as SqlOutParameter.

Parameters:
parameter - the SqlParameter to add

addDeclaredRowMapper

public void addDeclaredRowMapper(java.lang.String parameterName,
                                 RowMapper rowMapper)
Add a RowMapper for the specified parameter or column.

Parameters:
parameterName - name of parameter or column
rowMapper - the RowMapper implementation to use

addDeclaredRowMapper

@Deprecated
public void addDeclaredRowMapper(java.lang.String parameterName,
                                            ParameterizedRowMapper rowMapper)
Deprecated. in favor of addDeclaredRowMapper(String, org.springframework.jdbc.core.RowMapper)

Add a RowMapper for the specified parameter or column.


getCallString

public java.lang.String getCallString()
Get the call string that should be used based on parameters and meta data.


setAccessCallParameterMetaData

public void setAccessCallParameterMetaData(boolean accessCallParameterMetaData)
Specify whether the parameter metadata for the call should be used. The default is true.


compile

public final void compile()
                   throws InvalidDataAccessApiUsageException
Compile this JdbcCall using provided parameters and meta data plus other settings. This finalizes the configuration for this object and subsequent attempts to compile are ignored. This will be implicitly called the first time an un-compiled call is executed.

Throws:
InvalidDataAccessApiUsageException - if the object hasn't been correctly initialized, for example if no DataSource has been provided

compileInternal

protected void compileInternal()
Method to perform the actual compilation. Subclasses can override this template method to perform their own compilation. Invoked after this base class's compilation is complete.


onCompileInternal

protected void onCompileInternal()
Hook method that subclasses may override to react to compilation. This implementation does nothing.


isCompiled

public boolean isCompiled()
Is this operation "compiled"?

Returns:
whether this operation is compiled, and ready to use.

checkCompiled

protected void checkCompiled()
Check whether this operation has been compiled already; lazily compile it if not already compiled.

Automatically called by doExecute.


doExecute

protected java.util.Map<java.lang.String,java.lang.Object> doExecute(SqlParameterSource parameterSource)
Method that provides execution of the call using the passed in SqlParameterSource

Parameters:
parameterSource - parameter names and values to be used in call
Returns:
Map of out parameters

doExecute

protected java.util.Map<java.lang.String,java.lang.Object> doExecute(java.lang.Object[] args)
Method that provides execution of the call using the passed in array of parameters

Parameters:
args - array of parameter values; order must match the order declared for the stored procedure
Returns:
Map of out parameters

doExecute

protected java.util.Map<java.lang.String,java.lang.Object> doExecute(java.util.Map<java.lang.String,?> args)
Method that provides execution of the call using the passed in Map of parameters

Parameters:
args - Map of parameter name and values
Returns:
Map of out parameters

getScalarOutParameterName

protected java.lang.String getScalarOutParameterName()
Get the name of a single out parameter or return value. Used for functions or procedures with one out parameter.


matchInParameterValuesWithCallParameters

protected java.util.Map<java.lang.String,java.lang.Object> matchInParameterValuesWithCallParameters(SqlParameterSource parameterSource)
Match the provided in parameter values with registered parameters and parameters defined via metadata processing.

Parameters:
parameterSource - the parameter vakues provided as a SqlParameterSource
Returns:
Map with parameter names and values

matchInParameterValuesWithCallParameters

protected java.util.Map<java.lang.String,?> matchInParameterValuesWithCallParameters(java.util.Map<java.lang.String,?> args)
Match the provided in parameter values with registered parameters and parameters defined via metadata processing.

Parameters:
args - the parameter values provided in a Map
Returns:
Map with parameter names and values

getCallParameters

protected java.util.List<SqlParameter> getCallParameters()
Get a List of all the call parameters to be used for call. This includes any parameters added based on meta data processing.


Spring Framework