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

public abstract Class AbstractJdbcCall

extends Object
Class Inheritance
Known Direct Subclasses
org.springframework.jdbc.core.simple.SimpleJdbcCall
Imports
java.util.ArrayList, .LinkedHashMap, .List, .Map, .Set, javax.sql.DataSource, org.apache.commons.logging.Log, .LogFactory, org.springframework.dao.InvalidDataAccessApiUsageException, org.springframework.jdbc.core.CallableStatementCreator, .CallableStatementCreatorFactory, .JdbcTemplate, .RowMapper, .SqlParameter, org.springframework.jdbc.core.metadata.CallMetaDataContext, org.springframework.jdbc.core.namedparam.SqlParameterSource, org.springframework.lang.Nullable, org.springframework.util.Assert, .StringUtils

Abstract class to provide base functionality for easy stored procedure calls based on configuration options and database meta-data.

This class provides the processing arrangement for SimpleJdbcCall.

Authors
Thomas Risberg, Juergen Hoeller
Since
2.5

Field Summary

Modifier and TypeField and Description
private CallableStatementCreatorFactory
callableStatementFactory

A delegate enabling us to create CallableStatementCreators efficiently, based on this class's declared parameters.

private final CallMetaDataContext
callMetaDataContext

Context used to retrieve and manage database meta-data.

private String
callString

The generated string used for call statement.

private volatile boolean
compiled

Has this operation been compiled?

private final List<SqlParameter>
declaredParameters

List of SqlParameter objects.

private final Map<String, RowMapper<?>>
declaredRowMappers

List of RefCursor/ResultSet RowMapper objects.

private final JdbcTemplate
jdbcTemplate

Lower-level class used to execute SQL.

protected final Log
logger

Logger available to subclasses.

Constructor Summary

AccessConstructor and Description
protected
AbstractJdbcCall(DataSource
the DataSource to be used
dataSource
)

Constructor to be used when initializing using a DataSource.

protected
AbstractJdbcCall(JdbcTemplate
the JdbcTemplate to use
jdbcTemplate
)

Constructor to be used when initializing using a JdbcTemplate.

Method Summary

Modifier and TypeMethod and Description
public void
addDeclaredParameter(SqlParameter
the SqlParameter to add
parameter
)

Add a declared parameter to the list of parameters for the call.

public void
addDeclaredRowMapper(String
name of parameter or column
parameterName
,
RowMapper<?>
the RowMapper implementation to use
rowMapper
)

Add a org.springframework.jdbc.core.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.

public final synchronized void
compile()

Compile this JdbcCall using provided parameters and meta-data plus other settings.

protected void
compileInternal()

Delegate method to perform the actual compilation.

protected Map<String, Object>

Returns:

a Map of out parameters
doExecute
(SqlParameterSource
parameter names and values to be used in call
parameterSource
)

Delegate method that executes the call using the passed-in SqlParameterSource.

protected Map<String, Object>

Returns:

a Map of out parameters
doExecute
(Object...
array of parameter values. The order of values must match the order declared for the stored procedure.
args
)

Delegate method that executes the call using the passed-in array of parameters.

protected Map<String, Object>

Returns:

a Map of out parameters
doExecute
(Map<String, ?>
a Map of parameter name and values
args
)

Delegate method that executes the call using the passed-in Map of parameters.

private Map<String, Object>
executeCallInternal(Map<String, ?> args)

Delegate method to perform the actual call processing.

protected CallableStatementCreatorFactory
protected List<SqlParameter>
getCallParameters()

Get a List of all the call parameters to be used for call.

public String
getCallString()

Get the call string that should be used based on parameters and meta-data.

public String
getCatalogName()

Get the catalog name used.

public Set<String>
getInParameterNames()

Get the names of in parameters to be used.

public JdbcTemplate
getJdbcTemplate()

Get the configured JdbcTemplate.

public String
getProcedureName()

Get the name of the stored procedure.

protected String
getScalarOutParameterName()

Get the name of a single out parameter or return value.

public String
getSchemaName()

Get the schema name used.

public boolean

Returns:

whether this operation is compiled and ready to use
isCompiled
()

Is this operation "compiled"?

public boolean
isFunction()

Is this call a function call?

public boolean
isNamedBinding()

Should parameters be bound by name?

public boolean
isReturnValueRequired()

Does the call require a return value?

protected Map<String, Object>

Returns:

a Map with parameter names and values
matchInParameterValuesWithCallParameters
(SqlParameterSource
the parameter values provided as a SqlParameterSource
parameterSource
)

Match the provided in parameter values with registered parameters and parameters defined via meta-data processing.

private Map<String, ?>

Returns:

a Map with parameter names and values
matchInParameterValuesWithCallParameters
(Object[]
the parameter values provided as an array
args
)

Match the provided in parameter values with registered parameters and parameters defined via meta-data processing.

protected Map<String, ?>

Returns:

a Map with parameter names and values
matchInParameterValuesWithCallParameters
(Map<String, ?>
the parameter values provided as a Map
args
)

Match the provided in parameter values with registered parameters and parameters defined via meta-data processing.

protected void
onCompileInternal()

Hook method that subclasses may override to react to compilation.

public void
setAccessCallParameterMetaData(boolean accessCallParameterMetaData)

Specify whether the parameter meta-data for the call should be used.

public void
setCatalogName(String catalogName)

Set the catalog name to use.

public void
setFunction(boolean function)

Specify whether this call is a function call.

public void
setInParameterNames(Set<String> inParameterNames)

Set the names of in parameters to be used.

public void
setNamedBinding(boolean namedBinding)

Specify whether parameters should be bound by name.

public void
setProcedureName(String procedureName)

Set the name of the stored procedure.

public void
setReturnValueRequired(boolean returnValueRequired)

Specify whether the call requires a return value.

public void
setSchemaName(String schemaName)

Set the schema name to use.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

callableStatementFactoryback to summary
private CallableStatementCreatorFactory callableStatementFactory

A delegate enabling us to create CallableStatementCreators efficiently, based on this class's declared parameters.

Annotations
@Nullable
callMetaDataContextback to summary
private final CallMetaDataContext callMetaDataContext

Context used to retrieve and manage database meta-data.

callStringback to summary
private String callString

The generated string used for call statement.

Annotations
@Nullable
compiledback to summary
private volatile boolean compiled

Has this operation been compiled? Compilation means at least checking that a DataSource or JdbcTemplate has been provided.

declaredParametersback to summary
private final List<SqlParameter> declaredParameters

List of SqlParameter objects.

declaredRowMappersback to summary
private final Map<String, RowMapper<?>> declaredRowMappers

List of RefCursor/ResultSet RowMapper objects.

jdbcTemplateback to summary
private final JdbcTemplate jdbcTemplate

Lower-level class used to execute SQL.

loggerback to summary
protected final Log logger

Logger available to subclasses.

Constructor Detail

AbstractJdbcCallback to summary
protected AbstractJdbcCall(DataSource dataSource)

Constructor to be used when initializing using a DataSource.

Parameters
dataSource:DataSource

the DataSource to be used

AbstractJdbcCallback to summary
protected AbstractJdbcCall(JdbcTemplate jdbcTemplate)

Constructor to be used when initializing using a JdbcTemplate.

Parameters
jdbcTemplate:JdbcTemplate

the JdbcTemplate to use

Method Detail

addDeclaredParameterback to summary
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:SqlParameter

the SqlParameter to add

addDeclaredRowMapperback to summary
public void addDeclaredRowMapper(String parameterName, RowMapper<?> rowMapper)

Add a org.springframework.jdbc.core.RowMapper for the specified parameter or column.

Parameters
parameterName:String

name of parameter or column

rowMapper:RowMapper<?>

the RowMapper implementation to use

checkCompiledback to summary
protected void checkCompiled()

Check whether this operation has been compiled already; lazily compile it if not already compiled.

Automatically called by all doExecute(...) methods.

compileback to summary
public final synchronized 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.

Exceptions
InvalidDataAccessApiUsageException:
if the object hasn't been correctly initialized, for example if no DataSource has been provided
compileInternalback to summary
protected void compileInternal()

Delegate 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.

doExecuteback to summary
protected Map<String, Object> doExecute(SqlParameterSource parameterSource)

Delegate method that executes the call using the passed-in SqlParameterSource.

Parameters
parameterSource:SqlParameterSource

parameter names and values to be used in call

Returns:Map<String, Object>

a Map of out parameters

doExecuteback to summary
protected Map<String, Object> doExecute(Object... args)

Delegate method that executes the call using the passed-in array of parameters.

Parameters
args:Object[]

array of parameter values. The order of values must match the order declared for the stored procedure.

Returns:Map<String, Object>

a Map of out parameters

doExecuteback to summary
protected Map<String, Object> doExecute(Map<String, ?> args)

Delegate method that executes the call using the passed-in Map of parameters.

Parameters
args:Map<String, ?>

a Map of parameter name and values

Returns:Map<String, Object>

a Map of out parameters

executeCallInternalback to summary
private Map<String, Object> executeCallInternal(Map<String, ?> args)

Delegate method to perform the actual call processing.

getCallableStatementFactoryback to summary
protected CallableStatementCreatorFactory getCallableStatementFactory()

Get the CallableStatementCreatorFactory being used.

getCallParametersback to summary
protected 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.

getCallStringback to summary
public String getCallString()

Get the call string that should be used based on parameters and meta-data.

Annotations
@Nullable
getCatalogNameback to summary
public String getCatalogName()

Get the catalog name used.

Annotations
@Nullable
getInParameterNamesback to summary
public Set<String> getInParameterNames()

Get the names of in parameters to be used.

getJdbcTemplateback to summary
public JdbcTemplate getJdbcTemplate()

Get the configured JdbcTemplate.

getProcedureNameback to summary
public String getProcedureName()

Get the name of the stored procedure.

Annotations
@Nullable
getScalarOutParameterNameback to summary
protected String getScalarOutParameterName()

Get the name of a single out parameter or return value. Used for functions or procedures with one out parameter.

Annotations
@Nullable
getSchemaNameback to summary
public String getSchemaName()

Get the schema name used.

Annotations
@Nullable
isCompiledback to summary
public boolean isCompiled()

Is this operation "compiled"?

Returns:boolean

whether this operation is compiled and ready to use

isFunctionback to summary
public boolean isFunction()

Is this call a function call?

isNamedBindingback to summary
public boolean isNamedBinding()

Should parameters be bound by name?

Since
4.2
isReturnValueRequiredback to summary
public boolean isReturnValueRequired()

Does the call require a return value?

matchInParameterValuesWithCallParametersback to summary
protected Map<String, Object> matchInParameterValuesWithCallParameters(SqlParameterSource parameterSource)

Match the provided in parameter values with registered parameters and parameters defined via meta-data processing.

Parameters
parameterSource:SqlParameterSource

the parameter values provided as a SqlParameterSource

Returns:Map<String, Object>

a Map with parameter names and values

matchInParameterValuesWithCallParametersback to summary
private Map<String, ?> matchInParameterValuesWithCallParameters(Object[] args)

Match the provided in parameter values with registered parameters and parameters defined via meta-data processing.

Parameters
args:Object[]

the parameter values provided as an array

Returns:Map<String, ?>

a Map with parameter names and values

matchInParameterValuesWithCallParametersback to summary
protected Map<String, ?> matchInParameterValuesWithCallParameters(Map<String, ?> args)

Match the provided in parameter values with registered parameters and parameters defined via meta-data processing.

Parameters
args:Map<String, ?>

the parameter values provided as a Map

Returns:Map<String, ?>

a Map with parameter names and values

onCompileInternalback to summary
protected void onCompileInternal()

Hook method that subclasses may override to react to compilation. This implementation does nothing.

setAccessCallParameterMetaDataback to summary
public void setAccessCallParameterMetaData(boolean accessCallParameterMetaData)

Specify whether the parameter meta-data for the call should be used. The default is true.

setCatalogNameback to summary
public void setCatalogName(String catalogName)

Set the catalog name to use.

setFunctionback to summary
public void setFunction(boolean function)

Specify whether this call is a function call. The default is false.

setInParameterNamesback to summary
public void setInParameterNames(Set<String> inParameterNames)

Set the names of in parameters to be used.

setNamedBindingback to summary
public void setNamedBinding(boolean namedBinding)

Specify whether parameters should be bound by name. The default is false.

Since
4.2
setProcedureNameback to summary
public void setProcedureName(String procedureName)

Set the name of the stored procedure.

setReturnValueRequiredback to summary
public void setReturnValueRequired(boolean returnValueRequired)

Specify whether the call requires a return value. The default is false.

setSchemaNameback to summary
public void setSchemaName(String schemaName)

Set the schema name to use.