org.springframework.jdbc.core.metadata
Class CallMetaDataContext

java.lang.Object
  extended by org.springframework.jdbc.core.metadata.CallMetaDataContext

public class CallMetaDataContext
extends java.lang.Object

Class to manage context metadata used for the configuration and execution of the call.

Since:
2.5
Author:
Thomas Risberg, Juergen Hoeller

Field Summary
private  boolean accessCallParameterMetaData
          should we access call parameter meta data info or not
private  java.lang.String actualFunctionReturnName
          Actual name to use for the return value in the output map
private  java.util.List<SqlParameter> callParameters
          List of SqlParameter objects to be used in call execution
private  java.lang.String catalogName
          name of catalog for call
private  java.lang.String defaultFunctionReturnName
          Default name to use for the return value in the output map
private  boolean function
          indicates whether this is a procedure or a function
private  java.util.Set<java.lang.String> limitedInParameterNames
          Set of in parameter names to exclude use for any not listed
protected  Log logger
          Logger available to subclasses
private  CallMetaDataProvider metaDataProvider
          the provider of call meta data
private  java.util.List<java.lang.String> outParameterNames
          List of SqlParameter names for out parameters
private  java.lang.String procedureName
          name of procedure to call
private  boolean returnValueRequired
          indicates whether this procedure's return value should be included
private  java.lang.String schemaName
          name of schema for call
 
Constructor Summary
CallMetaDataContext()
           
 
Method Summary
 java.lang.String createCallString()
          Build the call string based on configuration and metadata information.
 SqlParameter createReturnResultSetParameter(java.lang.String parameterName, RowMapper rowMapper)
          Create a ReturnResultSetParameter/SqlOutParameter depending on the support provided by the JDBC driver used for the database in use.
 java.util.List<SqlParameter> getCallParameters()
          Get the List of SqlParameter objects to be used in call execution
 java.lang.String getCatalogName()
          Get the name of the catalog.
 java.lang.String getFunctionReturnName()
          Get the name used for the return value of the function.
 java.util.Set<java.lang.String> getLimitedInParameterNames()
          Get a limited set of in parameters to be used.
 java.util.List<java.lang.String> getOutParameterNames()
          Get a list of the out parameter names.
 java.lang.String getProcedureName()
          Get the name of the procedure.
 java.lang.String getScalarOutParameterName()
          Get the name of the single out parameter for this call.
 java.lang.String getSchemaName()
          Get the name of the schema.
 void initializeMetaData(javax.sql.DataSource dataSource)
          Initialize this class with metadata from the database
 boolean isAccessCallParameterMetaData()
          Check whether call parameter metadata should be accessed.
 boolean isFunction()
          Check whether this call is a function call.
 boolean isReturnValueRequired()
          Check whether a return value is required.
 java.util.Map<java.lang.String,?> matchInParameterValuesWithCallParameters(java.util.Map<java.lang.String,?> inParameters)
          Match input parameter values with the parameters declared to be used in the call.
 java.util.Map<java.lang.String,?> matchInParameterValuesWithCallParameters(java.lang.Object[] parameterValues)
           
 java.util.Map<java.lang.String,java.lang.Object> matchInParameterValuesWithCallParameters(SqlParameterSource parameterSource)
          Match input parameter values with the parameters declared to be used in the call.
 void processParameters(java.util.List<SqlParameter> parameters)
          Process the list of parameters provided and if procedure column metadata is used the parameters will be matched against the metadata information and any missing ones will be automatically included
protected  java.util.List<SqlParameter> reconcileParameters(java.util.List<SqlParameter> parameters)
          Reconcile the provided parameters with available metadata and add new ones where appropriate
 void setAccessCallParameterMetaData(boolean accessCallParameterMetaData)
          Specify whether call parameter metadata should be accessed.
 void setCatalogName(java.lang.String catalogName)
          Specify the name of the catalog.
 void setFunction(boolean function)
          Specify whether this call is a function call.
 void setFunctionReturnName(java.lang.String functionReturnName)
          Specify the name used for the return value of the function.
 void setLimitedInParameterNames(java.util.Set<java.lang.String> limitedInParameterNames)
          Specify a limited set of in parameters to be used.
 void setOutParameterNames(java.util.List<java.lang.String> outParameterNames)
          Specify the names of the out parameters.
 void setProcedureName(java.lang.String procedureName)
          Specify the name of the procedure.
 void setReturnValueRequired(boolean returnValueRequired)
          Specify whether a return value is required.
 void setSchemaName(java.lang.String schemaName)
          Secify the name of the schema.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

logger

protected final Log logger
Logger available to subclasses


procedureName

private java.lang.String procedureName
name of procedure to call


catalogName

private java.lang.String catalogName
name of catalog for call


schemaName

private java.lang.String schemaName
name of schema for call


callParameters

private java.util.List<SqlParameter> callParameters
List of SqlParameter objects to be used in call execution


defaultFunctionReturnName

private java.lang.String defaultFunctionReturnName
Default name to use for the return value in the output map


actualFunctionReturnName

private java.lang.String actualFunctionReturnName
Actual name to use for the return value in the output map


limitedInParameterNames

private java.util.Set<java.lang.String> limitedInParameterNames
Set of in parameter names to exclude use for any not listed


outParameterNames

private java.util.List<java.lang.String> outParameterNames
List of SqlParameter names for out parameters


accessCallParameterMetaData

private boolean accessCallParameterMetaData
should we access call parameter meta data info or not


function

private boolean function
indicates whether this is a procedure or a function


returnValueRequired

private boolean returnValueRequired
indicates whether this procedure's return value should be included


metaDataProvider

private CallMetaDataProvider metaDataProvider
the provider of call meta data

Constructor Detail

CallMetaDataContext

public CallMetaDataContext()
Method Detail

setFunctionReturnName

public void setFunctionReturnName(java.lang.String functionReturnName)
Specify the name used for the return value of the function.


getFunctionReturnName

public java.lang.String getFunctionReturnName()
Get the name used for the return value of the function.


setLimitedInParameterNames

public void setLimitedInParameterNames(java.util.Set<java.lang.String> limitedInParameterNames)
Specify a limited set of in parameters to be used.


getLimitedInParameterNames

public java.util.Set<java.lang.String> getLimitedInParameterNames()
Get a limited set of in parameters to be used.


setOutParameterNames

public void setOutParameterNames(java.util.List<java.lang.String> outParameterNames)
Specify the names of the out parameters.


getOutParameterNames

public java.util.List<java.lang.String> getOutParameterNames()
Get a list of the out parameter names.


setProcedureName

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


getProcedureName

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


setCatalogName

public void setCatalogName(java.lang.String catalogName)
Specify the name of the catalog.


getCatalogName

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


setSchemaName

public void setSchemaName(java.lang.String schemaName)
Secify the name of the schema.


getSchemaName

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


setFunction

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


isFunction

public boolean isFunction()
Check whether this call is a function call.


setReturnValueRequired

public void setReturnValueRequired(boolean returnValueRequired)
Specify whether a return value is required.


isReturnValueRequired

public boolean isReturnValueRequired()
Check whether a return value is required.


setAccessCallParameterMetaData

public void setAccessCallParameterMetaData(boolean accessCallParameterMetaData)
Specify whether call parameter metadata should be accessed.


isAccessCallParameterMetaData

public boolean isAccessCallParameterMetaData()
Check whether call parameter metadata should be accessed.


createReturnResultSetParameter

public SqlParameter createReturnResultSetParameter(java.lang.String parameterName,
                                                   RowMapper rowMapper)
Create a ReturnResultSetParameter/SqlOutParameter depending on the support provided by the JDBC driver used for the database in use.

Parameters:
parameterName - the name of the parameter (also used as the name of the List returned in the output)
rowMapper - a RowMapper implementation used to map the data returned in the result set
Returns:
the appropriate SqlParameter

getScalarOutParameterName

public java.lang.String getScalarOutParameterName()
Get the name of the single out parameter for this call. If there are multiple parameters then the name of the first one is returned.


getCallParameters

public java.util.List<SqlParameter> getCallParameters()
Get the List of SqlParameter objects to be used in call execution


initializeMetaData

public void initializeMetaData(javax.sql.DataSource dataSource)
Initialize this class with metadata from the database

Parameters:
dataSource - the DataSource used to retrieve metadata

processParameters

public void processParameters(java.util.List<SqlParameter> parameters)
Process the list of parameters provided and if procedure column metadata is used the parameters will be matched against the metadata information and any missing ones will be automatically included

Parameters:
parameters - the list of parameters to use as a base

reconcileParameters

protected java.util.List<SqlParameter> reconcileParameters(java.util.List<SqlParameter> parameters)
Reconcile the provided parameters with available metadata and add new ones where appropriate


matchInParameterValuesWithCallParameters

public java.util.Map<java.lang.String,java.lang.Object> matchInParameterValuesWithCallParameters(SqlParameterSource parameterSource)
Match input parameter values with the parameters declared to be used in the call.

Parameters:
parameterSource - the input values
Returns:
a Map containing the matched parameter names with the value taken from the input

matchInParameterValuesWithCallParameters

public java.util.Map<java.lang.String,?> matchInParameterValuesWithCallParameters(java.util.Map<java.lang.String,?> inParameters)
Match input parameter values with the parameters declared to be used in the call.

Parameters:
inParameters - the input values
Returns:
a Map containing the matched parameter names with the value taken from the input

matchInParameterValuesWithCallParameters

public java.util.Map<java.lang.String,?> matchInParameterValuesWithCallParameters(java.lang.Object[] parameterValues)

createCallString

public java.lang.String createCallString()
Build the call string based on configuration and metadata information.

Returns:
the call string to be used