001: /*
002: * Copyright 2002-2007 the original author or authors.
003: *
004: * Licensed under the Apache License, Version 2.0 (the "License");
005: * you may not use this file except in compliance with the License.
006: * You may obtain a copy of the License at
007: *
008: * http://www.apache.org/licenses/LICENSE-2.0
009: *
010: * Unless required by applicable law or agreed to in writing, software
011: * distributed under the License is distributed on an "AS IS" BASIS,
012: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013: * See the License for the specific language governing permissions and
014: * limitations under the License.
015: */
016:
017: package org.springframework.jdbc.core.simple;
018:
019: import java.util.Map;
020:
021: import org.springframework.jdbc.core.SqlParameter;
022: import org.springframework.jdbc.core.namedparam.MapSqlParameterSource;
023: import org.springframework.jdbc.core.namedparam.SqlParameterSource;
024:
025: /**
026: * Interface specifying the API for a Simple JDBC Call implemented by {@link SimpleJdbcCall}.
027: * This interface is not often used directly, but provides the
028: * option to enhance testability, as it can easily be mocked or stubbed.
029: *
030: * @author Thomas Risberg
031: * @since 2.5
032: */
033: public interface SimpleJdbcCallOperations {
034:
035: /**
036: * Specify the procedure name to be used - this implies that we will be calling a stored procedure.
037: * @param procedureName the name of the stored procedure
038: * @return the instance of this SimpleJdbcCall
039: */
040: SimpleJdbcCallOperations withProcedureName(String procedureName);
041:
042: /**
043: * Specify the procedure name to be used - this implies that we will be calling a stored function.
044: * @param functionName the name of the stored function
045: * @return the instance of this SimpleJdbcCall
046: */
047: SimpleJdbcCallOperations withFunctionName(String functionName);
048:
049: /**
050: * Optionally, specify the name of the schema that contins the stored procedure.
051: * @param schemaName the name of the schema
052: * @return the instance of this SimpleJdbcCall
053: */
054: SimpleJdbcCallOperations withSchemaName(String schemaName);
055:
056: /**
057: * Optionally, specify the name of the catalog that contins the stored procedure.
058: * To provide consistency with the Oracle DatabaseMetaData, this is used to specify the package name if
059: * the procedure is declared as part of a package.
060: * @param catalogName the catalog or package name
061: * @return the instance of this SimpleJdbcCall
062: */
063: SimpleJdbcCallOperations withCatalogName(String catalogName);
064:
065: /**
066: * Indicates the procedure's return value should be included in the results returned.
067: * @return the instance of this SimpleJdbcCall
068: */
069: SimpleJdbcCallOperations withReturnValue();
070:
071: /**
072: * Specify one or more parameters if desired. These parameters will be supplemented with any
073: * parameter information retrieved from the database meta data.
074: * @param sqlParameters the parameters to use
075: * @return the instance of this SimpleJdbcCall
076: */
077: SimpleJdbcCallOperations declareParameters(
078: SqlParameter... sqlParameters);
079:
080: /** Not used yet */
081: SimpleJdbcCallOperations useInParameterNames(
082: String... inParameterNames);
083:
084: /**
085: * Used to specify when a ResultSet is returned by the stored procedure and you want it mapped
086: * by a RowMapper. The results will be returned using the parameter name specified. Multiple
087: * ResultSets must be declared in the correct order. If the database you are using uses ref cursors
088: * then the name specified must match the name of the parameter declared for the procedure in the
089: * database.
090: * @param parameterName the name of the returned results and/or the name of the ref cursor parameter
091: * @param rowMapper the RowMapper implementation that will map the data returned for each row
092: * */
093: SimpleJdbcCallOperations returningResultSet(String parameterName,
094: ParameterizedRowMapper rowMapper);
095:
096: /**
097: * Turn off any processing of parameter meta data information obtained via JDBC.
098: * @return the instance of this SimpleJdbcCall
099: */
100: SimpleJdbcCallOperations withoutProcedureColumnMetaDataAccess();
101:
102: /**
103: * Execute the stored function and return the results obtained as an Object of the specified return type.
104: * @param returnType the type of the value to return
105: * @param args Map containing the parameter values to be used in the call.
106: */
107: <T> T executeFunction(Class<T> returnType, Map args);
108:
109: /**
110: * Execute the stored function and return the results obtained as an Object of the specified return type.
111: * @param returnType the type of the value to return
112: * @param args MapSqlParameterSource containing the parameter values to be used in the call.
113: */
114: <T> T executeFunction(Class<T> returnType,
115: MapSqlParameterSource args);
116:
117: /**
118: * Execute the stored procedure and return the single out parameter as an Object of the specified return type.
119: * In the case where there are multiple out parameters, the first one is returned and additional out parameters
120: * are ignored.
121: * @param returnType the type of the value to return
122: * @param args Map containing the parameter values to be used in the call.
123: */
124: <T> T executeObject(Class<T> returnType, Map args);
125:
126: /**
127: * Execute the stored procedure and return the single out parameter as an Object of the specified return type.
128: * In the case where there are multiple out parameters, the first one is returned and additional out parameters
129: * are ignored.
130: * @param returnType the type of the value to return
131: * @param args MapSqlParameterSource containing the parameter values to be used in the call.
132: */
133: <T> T executeObject(Class<T> returnType, MapSqlParameterSource args);
134:
135: /**
136: * Execute the stored procedure and return a map of output params, keyed by name as in parameter declarations..
137: * @return map of output params.
138: */
139: Map<String, Object> execute();
140:
141: /**
142: * Execute the stored procedure and return a map of output params, keyed by name as in parameter declarations..
143: * @param args Map containing the parameter values to be used in the call.
144: * @return map of output params.
145: */
146: Map<String, Object> execute(Map<String, Object> args);
147:
148: /**
149: * Execute the stored procedure and return a map of output params, keyed by name as in parameter declarations..
150: * @param args SqlParameterSource containing the parameter values to be used in the call.
151: * @return map of output params.
152: */
153: Map<String, Object> execute(SqlParameterSource args);
154:
155: }
|