Top Description Fields Constructors Methods
org.springframework.jdbc.core.metadata

public Class CallMetaDataContext

extends Object
Class Inheritance
Imports
java.util.ArrayList, .HashSet, .LinkedHashMap, .List, .Locale, .Map, .Set, javax.sql.DataSource, org.apache.commons.logging.Log, .LogFactory, org.springframework.dao.InvalidDataAccessApiUsageException, org.springframework.jdbc.core.RowMapper, .SqlOutParameter, .SqlParameter, .SqlParameterValue, .SqlReturnResultSet, org.springframework.jdbc.core.namedparam.SqlParameterSource, .SqlParameterSourceUtils, org.springframework.jdbc.support.JdbcUtils, org.springframework.lang.Nullable, org.springframework.util.Assert, .CollectionUtils, .StringUtils

Class to manage context meta-data used for the configuration and execution of a stored procedure call.
Authors
Thomas Risberg, Juergen Hoeller, Kiril Nugmanov
Since
2.5

Field Summary

Modifier and TypeField and Description
private boolean
private String
private List<SqlParameter>
private String
private boolean
private Set<String>
protected final Log
private CallMetaDataProvider
private boolean
private List<String>
private String
private boolean
private String

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public String

Returns:

the call string to be used
createCallString
()

Build the call string based on configuration and meta-data information.

protected String

Returns:

parameter binding fragment
createParameterBinding
(SqlParameter
call parameter
parameter
)

Build the parameter binding fragment.

public SqlParameter

Returns:

the appropriate SqlParameter
createReturnResultSetParameter
(String
the name of the parameter (also used as the name of the List returned in the output)
parameterName
,
RowMapper<?>
a RowMapper implementation used to map the data returned in the result set
rowMapper
)

Create a ReturnResultSetParameter/SqlOutParameter depending on the support provided by the JDBC driver used for the database in use.

public List<SqlParameter>
getCallParameters()

Get the List of SqlParameter objects to be used in call execution.

public String
getCatalogName()

Get the name of the catalog.

public String
getFunctionReturnName()

Get the name used for the return value of the function.

public Set<String>
getLimitedInParameterNames()

Get the limited set of the in parameters to be used.

public List<String>
getOutParameterNames()

Get the list of the out parameter names.

public String
getProcedureName()

Get the name of the procedure.

public String
getScalarOutParameterName()

Get the name of the single out parameter for this call.

public String
getSchemaName()

Get the name of the schema.

public void
initializeMetaData(DataSource
the DataSource used to retrieve meta-data
dataSource
)

Initialize this class with meta-data from the database.

public boolean
isAccessCallParameterMetaData()

Check whether call parameter meta-data should be accessed.

public boolean
isFunction()

Check whether this call is a function call.

public boolean
isNamedBinding()

Check whether parameters should be bound by name.

public boolean
isReturnValueRequired()

Check whether a return value is required.

private static String
lowerCase(String paramName)

public Map<String, Object>

Returns:

a Map containing the matched parameter names with the value taken from the input
matchInParameterValuesWithCallParameters
(SqlParameterSource
the input values
parameterSource
)

Match input parameter values with the parameters declared to be used in the call.

public Map<String, ?>

Returns:

a Map containing the matched parameter names with the value taken from the input
matchInParameterValuesWithCallParameters
(Map<String, ?>
the input values
inParameters
)

Match input parameter values with the parameters declared to be used in the call.

public Map<String, ?>
private CallMetaDataProvider
public void
processParameters(List<SqlParameter>
the list of parameters to use as a base
parameters
)

Process the list of parameters provided, and if procedure column meta-data is used, the parameters will be matched against the meta-data information and any missing ones will be automatically included.

protected List<SqlParameter>
reconcileParameters(List<SqlParameter> parameters)

Reconcile the provided parameters with available meta-data and add new ones where appropriate.

public void
setAccessCallParameterMetaData(boolean accessCallParameterMetaData)

Specify whether call parameter meta-data should be accessed.

public void
setCatalogName(String catalogName)

Specify the name of the catalog.

public void
setFunction(boolean function)

Specify whether this call is a function call.

public void
setFunctionReturnName(String functionReturnName)

Specify the name used for the return value of the function.

public void
setLimitedInParameterNames(Set<String> limitedInParameterNames)

Specify a limited set of the in parameters to be used.

public void
setNamedBinding(boolean namedBinding)

Specify whether parameters should be bound by name.

public void
setOutParameterNames(List<String> outParameterNames)

Specify the names of the out parameters.

public void
setProcedureName(String procedureName)

Specify the name of the procedure.

public void
setReturnValueRequired(boolean returnValueRequired)

Specify whether a return value is required.

public void
setSchemaName(String schemaName)

Specify the name of the schema.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

accessCallParameterMetaDataback to summary
private boolean accessCallParameterMetaData
actualFunctionReturnNameback to summary
private String actualFunctionReturnName
Annotations
@Nullable
callParametersback to summary
private List<SqlParameter> callParameters
catalogNameback to summary
private String catalogName
Annotations
@Nullable
functionback to summary
private boolean function
limitedInParameterNamesback to summary
private Set<String> limitedInParameterNames
loggerback to summary
protected final Log logger
metaDataProviderback to summary
private CallMetaDataProvider metaDataProvider
Annotations
@Nullable
namedBindingback to summary
private boolean namedBinding
outParameterNamesback to summary
private List<String> outParameterNames
procedureNameback to summary
private String procedureName
Annotations
@Nullable
returnValueRequiredback to summary
private boolean returnValueRequired
schemaNameback to summary
private String schemaName
Annotations
@Nullable

Constructor Detail

CallMetaDataContextback to summary
public CallMetaDataContext()

Method Detail

createCallStringback to summary
public String createCallString()

Build the call string based on configuration and meta-data information.

Returns:String

the call string to be used

createParameterBindingback to summary
protected String createParameterBinding(SqlParameter parameter)

Build the parameter binding fragment.

Parameters
parameter:SqlParameter

call parameter

Returns:String

parameter binding fragment

Since
4.2
createReturnResultSetParameterback to summary
public SqlParameter createReturnResultSetParameter(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:String

the name of the parameter (also used as the name of the List returned in the output)

rowMapper:RowMapper<?>

a RowMapper implementation used to map the data returned in the result set

Returns:SqlParameter

the appropriate SqlParameter

getCallParametersback to summary
public List<SqlParameter> getCallParameters()

Get the List of SqlParameter objects to be used in call execution.

getCatalogNameback to summary
public String getCatalogName()

Get the name of the catalog.

Annotations
@Nullable
getFunctionReturnNameback to summary
public String getFunctionReturnName()

Get the name used for the return value of the function.

getLimitedInParameterNamesback to summary
public Set<String> getLimitedInParameterNames()

Get the limited set of the in parameters to be used.

getOutParameterNamesback to summary
public List<String> getOutParameterNames()

Get the list of the out parameter names.

getProcedureNameback to summary
public String getProcedureName()

Get the name of the procedure.

Annotations
@Nullable
getScalarOutParameterNameback to summary
public String getScalarOutParameterName()

Get the name of the single out parameter for this call. If there are multiple parameters, the name of the first one will be returned.

Annotations
@Nullable
getSchemaNameback to summary
public String getSchemaName()

Get the name of the schema.

Annotations
@Nullable
initializeMetaDataback to summary
public void initializeMetaData(DataSource dataSource)

Initialize this class with meta-data from the database.

Parameters
dataSource:DataSource

the DataSource used to retrieve meta-data

isAccessCallParameterMetaDataback to summary
public boolean isAccessCallParameterMetaData()

Check whether call parameter meta-data should be accessed.

isFunctionback to summary
public boolean isFunction()

Check whether this call is a function call.

isNamedBindingback to summary
public boolean isNamedBinding()

Check whether parameters should be bound by name.

Since
4.2
isReturnValueRequiredback to summary
public boolean isReturnValueRequired()

Check whether a return value is required.

lowerCaseback to summary
private static String lowerCase(String paramName)
matchInParameterValuesWithCallParametersback to summary
public Map<String, Object> matchInParameterValuesWithCallParameters(SqlParameterSource parameterSource)

Match input parameter values with the parameters declared to be used in the call.

Parameters
parameterSource:SqlParameterSource

the input values

Returns:Map<String, Object>

a Map containing the matched parameter names with the value taken from the input

matchInParameterValuesWithCallParametersback to summary
public Map<String, ?> matchInParameterValuesWithCallParameters(Map<String, ?> inParameters)

Match input parameter values with the parameters declared to be used in the call.

Parameters
inParameters:Map<String, ?>

the input values

Returns:Map<String, ?>

a Map containing the matched parameter names with the value taken from the input

matchInParameterValuesWithCallParametersback to summary
public Map<String, ?> matchInParameterValuesWithCallParameters(Object[] parameterValues)
obtainMetaDataProviderback to summary
private CallMetaDataProvider obtainMetaDataProvider()
processParametersback to summary
public void processParameters(List<SqlParameter> parameters)

Process the list of parameters provided, and if procedure column meta-data is used, the parameters will be matched against the meta-data information and any missing ones will be automatically included.

Parameters
parameters:List<SqlParameter>

the list of parameters to use as a base

reconcileParametersback to summary
protected List<SqlParameter> reconcileParameters(List<SqlParameter> parameters)

Reconcile the provided parameters with available meta-data and add new ones where appropriate.

setAccessCallParameterMetaDataback to summary
public void setAccessCallParameterMetaData(boolean accessCallParameterMetaData)

Specify whether call parameter meta-data should be accessed.

setCatalogNameback to summary
public void setCatalogName(String catalogName)

Specify the name of the catalog.

setFunctionback to summary
public void setFunction(boolean function)

Specify whether this call is a function call.

setFunctionReturnNameback to summary
public void setFunctionReturnName(String functionReturnName)

Specify the name used for the return value of the function.

setLimitedInParameterNamesback to summary
public void setLimitedInParameterNames(Set<String> limitedInParameterNames)

Specify a limited set of the in parameters to be used.

setNamedBindingback to summary
public void setNamedBinding(boolean namedBinding)

Specify whether parameters should be bound by name.

Since
4.2
setOutParameterNamesback to summary
public void setOutParameterNames(List<String> outParameterNames)

Specify the names of the out parameters.

setProcedureNameback to summary
public void setProcedureName(String procedureName)

Specify the name of the procedure.

setReturnValueRequiredback to summary
public void setReturnValueRequired(boolean returnValueRequired)

Specify whether a return value is required.

setSchemaNameback to summary
public void setSchemaName(String schemaName)

Specify the name of the schema.