|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.springframework.jdbc.core.simple.AbstractJdbcCall org.springframework.jdbc.core.simple.SimpleJdbcCall
public class SimpleJdbcCall
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 mete 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 to provide the ability to string multiple ones together in a "fluid" interface style.
DatabaseMetaData
,
JdbcTemplate
Field Summary |
---|
Fields inherited from class org.springframework.jdbc.core.simple.AbstractJdbcCall |
---|
logger |
Constructor Summary | |
---|---|
SimpleJdbcCall(DataSource dataSource)
Constructor that takes one parameter with the JDBC DataSource to use when creating the JdbcTemplate. |
|
SimpleJdbcCall(JdbcTemplate jdbcTemplate)
Alternative Constructor that takes one parameter with the JdbcTemplate to be used. |
Method Summary | ||
---|---|---|
SimpleJdbcCall |
declareParameters(SqlParameter... sqlParameters)
Specify one or more parameters if desired. |
|
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(Object... 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.. |
|
|
executeFunction(Class<T> returnType,
Map<String,?> args)
Execute the stored function and return the results obtained as an Object of the specified return type. |
|
|
executeFunction(Class<T> returnType,
Object... args)
Execute the stored function and return the results obtained as an Object of the specified return type. |
|
|
executeFunction(Class<T> returnType,
SqlParameterSource args)
Execute the stored function and return the results obtained as an Object of the specified return type. |
|
|
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. |
|
|
executeObject(Class<T> returnType,
Object... args)
Execute the stored procedure and return the single out parameter as an Object of the specified return type. |
|
|
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,
ParameterizedRowMapper rowMapper)
Deprecated. in favor of returningResultSet(String, org.springframework.jdbc.core.RowMapper) |
|
SimpleJdbcCall |
returningResultSet(String parameterName,
RowMapper rowMapper)
Used to specify when a ResultSet is returned by the stored procedure and you want it mapped by a RowMapper. |
|
SimpleJdbcCall |
useInParameterNames(String... inParameterNames)
Not used yet |
|
SimpleJdbcCall |
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 |
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. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public SimpleJdbcCall(DataSource dataSource)
dataSource
- the DataSource
to useJdbcAccessor.setDataSource(javax.sql.DataSource)
public SimpleJdbcCall(JdbcTemplate jdbcTemplate)
jdbcTemplate
- the JdbcTemplate
to useJdbcAccessor.setDataSource(javax.sql.DataSource)
Method Detail |
---|
public SimpleJdbcCall withProcedureName(String procedureName)
SimpleJdbcCallOperations
withProcedureName
in interface SimpleJdbcCallOperations
procedureName
- the name of the stored procedure
public SimpleJdbcCall withFunctionName(String functionName)
SimpleJdbcCallOperations
withFunctionName
in interface SimpleJdbcCallOperations
functionName
- the name of the stored function
public SimpleJdbcCall withSchemaName(String schemaName)
SimpleJdbcCallOperations
withSchemaName
in interface SimpleJdbcCallOperations
schemaName
- the name of the schema
public SimpleJdbcCall withCatalogName(String catalogName)
SimpleJdbcCallOperations
withCatalogName
in interface SimpleJdbcCallOperations
catalogName
- the catalog or package name
public SimpleJdbcCall withReturnValue()
SimpleJdbcCallOperations
withReturnValue
in interface SimpleJdbcCallOperations
public SimpleJdbcCall declareParameters(SqlParameter... sqlParameters)
SimpleJdbcCallOperations
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
.
declareParameters
in interface SimpleJdbcCallOperations
sqlParameters
- the parameters to use
public SimpleJdbcCall useInParameterNames(String... inParameterNames)
SimpleJdbcCallOperations
useInParameterNames
in interface SimpleJdbcCallOperations
public SimpleJdbcCall returningResultSet(String parameterName, RowMapper rowMapper)
SimpleJdbcCallOperations
returningResultSet
in interface 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@Deprecated public SimpleJdbcCall returningResultSet(String parameterName, ParameterizedRowMapper rowMapper)
returningResultSet(String, org.springframework.jdbc.core.RowMapper)
SimpleJdbcCallOperations
returningResultSet
in interface SimpleJdbcCallOperations
public SimpleJdbcCall withoutProcedureColumnMetaDataAccess()
SimpleJdbcCallOperations
withoutProcedureColumnMetaDataAccess
in interface SimpleJdbcCallOperations
public <T> T executeFunction(Class<T> returnType, Object... args)
SimpleJdbcCallOperations
executeFunction
in interface 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.public <T> T executeFunction(Class<T> returnType, Map<String,?> args)
SimpleJdbcCallOperations
executeFunction
in interface SimpleJdbcCallOperations
returnType
- the type of the value to returnargs
- Map containing the parameter values to be used in the call.public <T> T executeFunction(Class<T> returnType, SqlParameterSource args)
SimpleJdbcCallOperations
executeFunction
in interface SimpleJdbcCallOperations
returnType
- the type of the value to returnargs
- MapSqlParameterSource containing the parameter values to be used in the call.public <T> T executeObject(Class<T> returnType, Object... args)
SimpleJdbcCallOperations
executeObject
in interface 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.public <T> T executeObject(Class<T> returnType, Map<String,?> args)
SimpleJdbcCallOperations
executeObject
in interface SimpleJdbcCallOperations
returnType
- the type of the value to returnargs
- Map containing the parameter values to be used in the call.public <T> T executeObject(Class<T> returnType, SqlParameterSource args)
SimpleJdbcCallOperations
executeObject
in interface SimpleJdbcCallOperations
returnType
- the type of the value to returnargs
- MapSqlParameterSource containing the parameter values to be used in the call.public Map<String,Object> execute(Object... args)
SimpleJdbcCallOperations
execute
in interface 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.
public Map<String,Object> execute(Map<String,?> args)
SimpleJdbcCallOperations
execute
in interface SimpleJdbcCallOperations
args
- Map containing the parameter values to be used in the call.
public Map<String,Object> execute(SqlParameterSource parameterSource)
SimpleJdbcCallOperations
execute
in interface SimpleJdbcCallOperations
parameterSource
- SqlParameterSource containing the parameter values to be used in the call.
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |