类 AbstractJdbcCall
- java.lang.Object
- org.springframework.jdbc.core.simple.AbstractJdbcCall
- 直接已知子类:
SimpleJdbcCall
public abstract class AbstractJdbcCall extends Object
Abstract class to provide base functionality for easy stored procedure calls based on configuration options and database meta-data.This class provides the base SPI for
SimpleJdbcCall
.- 从以下版本开始:
- 2.5
- 作者:
- Thomas Risberg, Juergen Hoeller
构造器概要
构造器 限定符 构造器 说明 protected
AbstractJdbcCall(DataSource dataSource)
Constructor to be used when initializing using aDataSource
.protected
AbstractJdbcCall(JdbcTemplate jdbcTemplate)
Constructor to be used when initializing using aJdbcTemplate
.
方法概要
所有方法 实例方法 具体方法 修饰符和类型 方法 说明 void
addDeclaredParameter(SqlParameter parameter)
Add a declared parameter to the list of parameters for the call.void
addDeclaredRowMapper(String parameterName, RowMapper<?> rowMapper)
Add aRowMapper
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()
Delegate method to perform the actual compilation.protected Map<String,Object>
doExecute(Object... args)
Delegate method that executes the call using the passed-in array of parameters.protected Map<String,Object>
doExecute(Map<String,?> args)
Delegate method that executes the call using the passed-in Map of parameters.protected Map<String,Object>
doExecute(SqlParameterSource parameterSource)
Delegate method that executes the call using the passed-inSqlParameterSource
.protected CallableStatementCreatorFactory
getCallableStatementFactory()
Get theCallableStatementCreatorFactory
being used.protected List<SqlParameter>
getCallParameters()
Get a List of all the call parameters to be used for call.String
getCallString()
Get the call string that should be used based on parameters and meta-data.String
getCatalogName()
Get the catalog name used.Set<String>
getInParameterNames()
Get the names of in parameters to be used.JdbcTemplate
getJdbcTemplate()
Get the configuredJdbcTemplate
.String
getProcedureName()
Get the name of the stored procedure.protected String
getScalarOutParameterName()
Get the name of a single out parameter or return value.String
getSchemaName()
Get the schema name used.boolean
isCompiled()
Is this operation "compiled"?boolean
isFunction()
Is this call a function call?boolean
isNamedBinding()
Should parameters be bound by name?boolean
isReturnValueRequired()
Does the call require a return value?protected Map<String,?>
matchInParameterValuesWithCallParameters(Map<String,?> args)
Match the provided in parameter values with registered parameters and parameters defined via meta-data processing.protected Map<String,Object>
matchInParameterValuesWithCallParameters(SqlParameterSource parameterSource)
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.void
setAccessCallParameterMetaData(boolean accessCallParameterMetaData)
Specify whether the parameter meta-data for the call should be used.void
setCatalogName(String catalogName)
Set the catalog name to use.void
setFunction(boolean function)
Specify whether this call is a function call.void
setInParameterNames(Set<String> inParameterNames)
Set the names of in parameters to be used.void
setNamedBinding(boolean namedBinding)
Specify whether parameters should be bound by name.void
setProcedureName(String procedureName)
Set the name of the stored procedure.void
setReturnValueRequired(boolean returnValueRequired)
Specify whether the call requires a return value.void
setSchemaName(String schemaName)
Set the schema name to use.
构造器详细资料
AbstractJdbcCall
protected AbstractJdbcCall(DataSource dataSource)
Constructor to be used when initializing using aDataSource
.- 参数:
dataSource
- the DataSource to be used
AbstractJdbcCall
protected AbstractJdbcCall(JdbcTemplate jdbcTemplate)
Constructor to be used when initializing using aJdbcTemplate
.- 参数:
jdbcTemplate
- the JdbcTemplate to use
方法详细资料
getJdbcTemplate
public JdbcTemplate getJdbcTemplate()
Get the configuredJdbcTemplate
.
setProcedureName
public void setProcedureName(@Nullable String procedureName)
Set the name of the stored procedure.
getProcedureName
@Nullable public String getProcedureName()
Get the name of the stored procedure.
setInParameterNames
public void setInParameterNames(Set<String> inParameterNames)
Set the names of in parameters to be used.
getInParameterNames
public Set<String> getInParameterNames()
Get the names of in parameters to be used.
setCatalogName
public void setCatalogName(@Nullable String catalogName)
Set the catalog name to use.
getCatalogName
@Nullable public String getCatalogName()
Get the catalog name used.
setSchemaName
public void setSchemaName(@Nullable String schemaName)
Set the schema name to use.
getSchemaName
@Nullable public String getSchemaName()
Get the schema name used.
setFunction
public void setFunction(boolean function)
Specify whether this call is a function call. The default isfalse
.
isFunction
public boolean isFunction()
Is this call a function call?
setReturnValueRequired
public void setReturnValueRequired(boolean returnValueRequired)
Specify whether the call requires a return value. The default isfalse
.
isReturnValueRequired
public boolean isReturnValueRequired()
Does the call require a return value?
setNamedBinding
public void setNamedBinding(boolean namedBinding)
Specify whether parameters should be bound by name. The default isfalse
.- 从以下版本开始:
- 4.2
isNamedBinding
public boolean isNamedBinding()
Should parameters be bound by name?- 从以下版本开始:
- 4.2
setAccessCallParameterMetaData
public void setAccessCallParameterMetaData(boolean accessCallParameterMetaData)
Specify whether the parameter meta-data for the call should be used. The default istrue
.
getCallString
@Nullable public String getCallString()
Get the call string that should be used based on parameters and meta-data.
getCallableStatementFactory
protected CallableStatementCreatorFactory getCallableStatementFactory()
Get theCallableStatementCreatorFactory
being used.
addDeclaredParameter
public void addDeclaredParameter(SqlParameter parameter)
Add a declared parameter to the list of parameters for the call.Only parameters declared as
SqlParameter
andSqlInOutParameter
will be used to provide input values. This is different from theStoredProcedure
class which - for backwards compatibility reasons - allows input values to be provided for parameters declared asSqlOutParameter
.- 参数:
parameter
- theSqlParameter
to add
addDeclaredRowMapper
public void addDeclaredRowMapper(String parameterName, RowMapper<?> rowMapper)
Add aRowMapper
for the specified parameter or column.- 参数:
parameterName
- name of parameter or columnrowMapper
- the RowMapper implementation to use
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.
- 抛出:
InvalidDataAccessApiUsageException
- if the object hasn't been correctly initialized, for example if no DataSource has been provided
compileInternal
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.
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"?- 返回:
- 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 Map<String,Object> doExecute(SqlParameterSource parameterSource)
Delegate method that executes the call using the passed-inSqlParameterSource
.- 参数:
parameterSource
- parameter names and values to be used in call- 返回:
- a Map of out parameters
doExecute
protected Map<String,Object> doExecute(Object... args)
Delegate method that executes the call using the passed-in array of parameters.- 参数:
args
- array of parameter values. The order of values must match the order declared for the stored procedure.- 返回:
- a Map of out parameters
doExecute
protected Map<String,Object> doExecute(Map<String,?> args)
Delegate method that executes the call using the passed-in Map of parameters.- 参数:
args
- a Map of parameter name and values- 返回:
- a Map of out parameters
getScalarOutParameterName
@Nullable protected String getScalarOutParameterName()
Get the name of a single out parameter or return value. Used for functions or procedures with one out parameter.
getCallParameters
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.
matchInParameterValuesWithCallParameters
protected Map<String,Object> matchInParameterValuesWithCallParameters(SqlParameterSource parameterSource)
Match the provided in parameter values with registered parameters and parameters defined via meta-data processing.- 参数:
parameterSource
- the parameter vakues provided as aSqlParameterSource
- 返回:
- a Map with parameter names and values
matchInParameterValuesWithCallParameters
protected Map<String,?> matchInParameterValuesWithCallParameters(Map<String,?> args)
Match the provided in parameter values with registered parameters and parameters defined via meta-data processing.- 参数:
args
- the parameter values provided in a Map- 返回:
- a Map with parameter names and values