类 SimpleJdbcCall
- java.lang.Object
- org.springframework.jdbc.core.simple.AbstractJdbcCall
- org.springframework.jdbc.core.simple.SimpleJdbcCall
- 所有已实现的接口:
SimpleJdbcCallOperations
public class SimpleJdbcCall extends AbstractJdbcCall implements SimpleJdbcCallOperations
A SimpleJdbcCall is a multi-threaded, reusable object representing a call to a stored procedure or a stored function. It provides meta-data processing to simplify the code needed to access basic stored procedures/functions. All you need to provide is the name of the procedure/function and a Map containing the parameters when you execute the call. The names of the supplied parameters will be matched up with in and out parameters declared when the stored procedure was created.The meta-data processing is based on the DatabaseMetaData provided by the JDBC driver. Since we rely on the JDBC driver, this "auto-detection" can only be used for databases that are known to provide accurate meta-data. These currently include Derby, MySQL, Microsoft SQL Server, Oracle, DB2, Sybase and PostgreSQL. For any other databases you are required to declare all parameters explicitly. You can of course declare all parameters explicitly even if the database provides the necessary meta-data. In that case your declared parameters will take precedence. You can also turn off any meta-data processing if you want to use parameter names that do not match what is declared during the stored procedure compilation.
The actual insert is being handled using Spring's
JdbcTemplate
.Many of the configuration methods return the current instance of the SimpleJdbcCall in order to provide the ability to chain multiple ones together in a "fluent" interface style.
- 从以下版本开始:
- 2.5
- 作者:
- Thomas Risberg, Stephane Nicoll
- 另请参阅:
DatabaseMetaData
,JdbcTemplate
字段概要
从类继承的字段 org.springframework.jdbc.core.simple.AbstractJdbcCall
logger
构造器概要
构造器 构造器 说明 SimpleJdbcCall(DataSource dataSource)
Constructor that takes one parameter with the JDBC DataSource to use when creating the underlying JdbcTemplate.SimpleJdbcCall(JdbcTemplate jdbcTemplate)
Alternative Constructor that takes one parameter with the JdbcTemplate to be used.
方法概要
所有方法 实例方法 具体方法 修饰符和类型 方法 说明 SimpleJdbcCall
declareParameters(SqlParameter... sqlParameters)
Specify one or more parameters if desired.Map<String,Object>
execute(Object... args)
Execute the stored procedure and return a map of output params, keyed by name as in parameter declarations.Map<String,Object>
execute(Map<String,?> args)
Execute the stored procedure and return a map of output params, keyed by name as in parameter declarations.Map<String,Object>
execute(SqlParameterSource parameterSource)
Execute the stored procedure and return a map of output params, keyed by name as in parameter declarations.<T> T
executeFunction(Class<T> returnType, Object... args)
Execute the stored function and return the results obtained as an Object of the specified return type.<T> T
executeFunction(Class<T> returnType, Map<String,?> args)
Execute the stored function and return the results obtained as an Object of the specified return type.<T> T
executeFunction(Class<T> returnType, SqlParameterSource args)
Execute the stored function and return the results obtained as an Object of the specified return type.<T> T
executeObject(Class<T> returnType, Object... args)
Execute the stored procedure and return the single out parameter as an Object of the specified return type.<T> T
executeObject(Class<T> returnType, Map<String,?> args)
Execute the stored procedure and return the single out parameter as an Object of the specified return type.<T> T
executeObject(Class<T> returnType, SqlParameterSource args)
Execute the stored procedure and return the single out parameter as an Object of the specified return type.SimpleJdbcCall
returningResultSet(String parameterName, RowMapper<?> rowMapper)
Used to specify when a ResultSet is returned by the stored procedure and you want it mapped by aRowMapper
.SimpleJdbcCall
useInParameterNames(String... inParameterNames)
Not used yetSimpleJdbcCall
withCatalogName(String catalogName)
Optionally, specify the name of the catalog that contins the stored procedure.SimpleJdbcCall
withFunctionName(String functionName)
Specify the procedure name to be used - this implies that we will be calling a stored function.SimpleJdbcCall
withNamedBinding()
Indicates that parameters should be bound by name.SimpleJdbcCall
withoutProcedureColumnMetaDataAccess()
Turn off any processing of parameter meta-data information obtained via JDBC.SimpleJdbcCall
withProcedureName(String procedureName)
Specify the procedure name to be used - this implies that we will be calling a stored procedure.SimpleJdbcCall
withReturnValue()
Indicates the procedure's return value should be included in the results returned.SimpleJdbcCall
withSchemaName(String schemaName)
Optionally, specify the name of the schema that contins the stored procedure.从类继承的方法 org.springframework.jdbc.core.simple.AbstractJdbcCall
addDeclaredParameter, addDeclaredRowMapper, checkCompiled, compile, compileInternal, doExecute, doExecute, doExecute, getCallableStatementFactory, getCallParameters, getCallString, getCatalogName, getInParameterNames, getJdbcTemplate, getProcedureName, getScalarOutParameterName, getSchemaName, isCompiled, isFunction, isNamedBinding, isReturnValueRequired, matchInParameterValuesWithCallParameters, matchInParameterValuesWithCallParameters, onCompileInternal, setAccessCallParameterMetaData, setCatalogName, setFunction, setInParameterNames, setNamedBinding, setProcedureName, setReturnValueRequired, setSchemaName
构造器详细资料
SimpleJdbcCall
public SimpleJdbcCall(DataSource dataSource)
Constructor that takes one parameter with the JDBC DataSource to use when creating the underlying JdbcTemplate.- 参数:
dataSource
- theDataSource
to use- 另请参阅:
JdbcAccessor.setDataSource(javax.sql.DataSource)
SimpleJdbcCall
public SimpleJdbcCall(JdbcTemplate jdbcTemplate)
Alternative Constructor that takes one parameter with the JdbcTemplate to be used.- 参数:
jdbcTemplate
- theJdbcTemplate
to use- 另请参阅:
JdbcAccessor.setDataSource(javax.sql.DataSource)
方法详细资料
withProcedureName
public SimpleJdbcCall withProcedureName(String procedureName)
从接口复制的说明:SimpleJdbcCallOperations
Specify the procedure name to be used - this implies that we will be calling a stored procedure.- 指定者:
withProcedureName
在接口中SimpleJdbcCallOperations
- 参数:
procedureName
- the name of the stored procedure- 返回:
- the instance of this SimpleJdbcCall
withFunctionName
public SimpleJdbcCall withFunctionName(String functionName)
从接口复制的说明:SimpleJdbcCallOperations
Specify the procedure name to be used - this implies that we will be calling a stored function.- 指定者:
withFunctionName
在接口中SimpleJdbcCallOperations
- 参数:
functionName
- the name of the stored function- 返回:
- the instance of this SimpleJdbcCall
withSchemaName
public SimpleJdbcCall withSchemaName(String schemaName)
从接口复制的说明:SimpleJdbcCallOperations
Optionally, specify the name of the schema that contins the stored procedure.- 指定者:
withSchemaName
在接口中SimpleJdbcCallOperations
- 参数:
schemaName
- the name of the schema- 返回:
- the instance of this SimpleJdbcCall
withCatalogName
public SimpleJdbcCall withCatalogName(String catalogName)
从接口复制的说明:SimpleJdbcCallOperations
Optionally, specify the name of the catalog that contins the stored procedure.To provide consistency with the Oracle DatabaseMetaData, this is used to specify the package name if the procedure is declared as part of a package.
- 指定者:
withCatalogName
在接口中SimpleJdbcCallOperations
- 参数:
catalogName
- the catalog or package name- 返回:
- the instance of this SimpleJdbcCall
withReturnValue
public SimpleJdbcCall withReturnValue()
从接口复制的说明:SimpleJdbcCallOperations
Indicates the procedure's return value should be included in the results returned.- 指定者:
withReturnValue
在接口中SimpleJdbcCallOperations
- 返回:
- the instance of this SimpleJdbcCall
declareParameters
public SimpleJdbcCall declareParameters(SqlParameter... sqlParameters)
从接口复制的说明:SimpleJdbcCallOperations
Specify one or more parameters if desired. These parameters will be supplemented with any parameter information retrieved from the database meta-data.Note that 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
.- 指定者:
declareParameters
在接口中SimpleJdbcCallOperations
- 参数:
sqlParameters
- the parameters to use- 返回:
- the instance of this SimpleJdbcCall
useInParameterNames
public SimpleJdbcCall useInParameterNames(String... inParameterNames)
从接口复制的说明:SimpleJdbcCallOperations
Not used yet
returningResultSet
public SimpleJdbcCall returningResultSet(String parameterName, RowMapper<?> rowMapper)
从接口复制的说明:SimpleJdbcCallOperations
Used to specify when a ResultSet is returned by the stored procedure and you want it mapped by aRowMapper
. The results will be returned using the parameter name specified. Multiple ResultSets must be declared in the correct order.If the database you are using uses ref cursors then the name specified must match the name of the parameter declared for the procedure in the database.
- 指定者:
returningResultSet
在接口中SimpleJdbcCallOperations
- 参数:
parameterName
- the name of the returned results and/or the name of the ref cursor parameterrowMapper
- the RowMapper implementation that will map the data returned for each row
withoutProcedureColumnMetaDataAccess
public SimpleJdbcCall withoutProcedureColumnMetaDataAccess()
从接口复制的说明:SimpleJdbcCallOperations
Turn off any processing of parameter meta-data information obtained via JDBC.- 指定者:
withoutProcedureColumnMetaDataAccess
在接口中SimpleJdbcCallOperations
- 返回:
- the instance of this SimpleJdbcCall
withNamedBinding
public SimpleJdbcCall withNamedBinding()
从接口复制的说明:SimpleJdbcCallOperations
Indicates that parameters should be bound by name.- 指定者:
withNamedBinding
在接口中SimpleJdbcCallOperations
- 返回:
- the instance of this SimpleJdbcCall
executeFunction
public <T> T executeFunction(Class<T> returnType, Object... args)
从接口复制的说明:SimpleJdbcCallOperations
Execute the stored function and return the results obtained as an Object of the specified return type.- 指定者:
executeFunction
在接口中SimpleJdbcCallOperations
- 参数:
returnType
- the type of the value to returnargs
- optional array containing the in parameter values to be used in the call. Parameter values must be provided in the same order as the parameters are defined for the stored procedure.
executeFunction
public <T> T executeFunction(Class<T> returnType, Map<String,?> args)
从接口复制的说明:SimpleJdbcCallOperations
Execute the stored function and return the results obtained as an Object of the specified return type.- 指定者:
executeFunction
在接口中SimpleJdbcCallOperations
- 参数:
returnType
- the type of the value to returnargs
- Map containing the parameter values to be used in the call
executeFunction
public <T> T executeFunction(Class<T> returnType, SqlParameterSource args)
从接口复制的说明:SimpleJdbcCallOperations
Execute the stored function and return the results obtained as an Object of the specified return type.- 指定者:
executeFunction
在接口中SimpleJdbcCallOperations
- 参数:
returnType
- the type of the value to returnargs
- MapSqlParameterSource containing the parameter values to be used in the call
executeObject
public <T> T executeObject(Class<T> returnType, Object... args)
从接口复制的说明:SimpleJdbcCallOperations
Execute the stored procedure and return the single out parameter as an Object of the specified return type. In the case where there are multiple out parameters, the first one is returned and additional out parameters are ignored.- 指定者:
executeObject
在接口中SimpleJdbcCallOperations
- 参数:
returnType
- the type of the value to returnargs
- optional array containing the in parameter values to be used in the call. Parameter values must be provided in the same order as the parameters are defined for the stored procedure.
executeObject
public <T> T executeObject(Class<T> returnType, Map<String,?> args)
从接口复制的说明:SimpleJdbcCallOperations
Execute the stored procedure and return the single out parameter as an Object of the specified return type. In the case where there are multiple out parameters, the first one is returned and additional out parameters are ignored.- 指定者:
executeObject
在接口中SimpleJdbcCallOperations
- 参数:
returnType
- the type of the value to returnargs
- Map containing the parameter values to be used in the call
executeObject
public <T> T executeObject(Class<T> returnType, SqlParameterSource args)
从接口复制的说明:SimpleJdbcCallOperations
Execute the stored procedure and return the single out parameter as an Object of the specified return type. In the case where there are multiple out parameters, the first one is returned and additional out parameters are ignored.- 指定者:
executeObject
在接口中SimpleJdbcCallOperations
- 参数:
returnType
- the type of the value to returnargs
- MapSqlParameterSource containing the parameter values to be used in the call
execute
public Map<String,Object> execute(Object... args)
从接口复制的说明:SimpleJdbcCallOperations
Execute the stored procedure and return a map of output params, keyed by name as in parameter declarations.- 指定者:
execute
在接口中SimpleJdbcCallOperations
- 参数:
args
- optional array containing the in parameter values to be used in the call. Parameter values must be provided in the same order as the parameters are defined for the stored procedure.- 返回:
- Map of output params
execute
public Map<String,Object> execute(Map<String,?> args)
从接口复制的说明:SimpleJdbcCallOperations
Execute the stored procedure and return a map of output params, keyed by name as in parameter declarations.- 指定者:
execute
在接口中SimpleJdbcCallOperations
- 参数:
args
- Map containing the parameter values to be used in the call- 返回:
- Map of output params
execute
public Map<String,Object> execute(SqlParameterSource parameterSource)
从接口复制的说明:SimpleJdbcCallOperations
Execute the stored procedure and return a map of output params, keyed by name as in parameter declarations.- 指定者:
execute
在接口中SimpleJdbcCallOperations
- 参数:
parameterSource
- SqlParameterSource containing the parameter values to be used in the call- 返回:
- Map of output params