added convenience execute method that takes vararg of objects in the order of the parameters plus the corresponding executeFunction/executeObject methods (SPR-4739)

This commit is contained in:
Thomas Risberg 2009-06-01 20:43:39 +00:00
parent 7c053127dd
commit fbd0be2d65
5 changed files with 277 additions and 202 deletions

View File

@ -540,6 +540,18 @@ public class CallMetaDataContext {
return matchedParameters;
}
public Map<String,?> matchInParameterValuesWithCallParameters(Object[] parameterValues) {
Map<String, Object> matchedParameters = new HashMap<String, Object>(parameterValues.length);
int i = 0;
for (SqlParameter parameter : this.callParameters) {
if (parameter.isInputValueProvided()) {
String parameterName = parameter.getName();
matchedParameters.put(parameterName, parameterValues[i++]);
}
}
return matchedParameters;
}
/**
* Build the call string based on configuration and metadata information.
* @return the call string to be used

View File

@ -341,6 +341,17 @@ public abstract class AbstractJdbcCall {
return executeCallInternal(params);
}
/**
* Method that provides execution of the call using the passed in array of parameters
* @param args array of parameter values; order must match the order declared for the stored procedure
* @return Map of out parameters
*/
protected Map<String, Object> doExecute(Object[] args) {
checkCompiled();
Map<String, ?> params = matchInParameterValuesWithCallParameters(args);
return executeCallInternal(params);
}
/**
* Method that provides execution of the call using the passed in Map of parameters
* @param args Map of parameter name and values
@ -385,6 +396,16 @@ public abstract class AbstractJdbcCall {
return this.callMetaDataContext.matchInParameterValuesWithCallParameters(parameterSource);
}
/**
* Match the provided in parameter values with registered parameters and
* parameters defined via metadata processing.
* @param args the parameter values provided as an array
* @return Map with parameter names and values
*/
private Map<String,?> matchInParameterValuesWithCallParameters(Object[] args) {
return this.callMetaDataContext.matchInParameterValuesWithCallParameters(args);
}
/**
* Match the provided in parameter values with registered parameters and
* parameters defined via metadata processing.

View File

@ -131,6 +131,10 @@ public class SimpleJdbcCall extends AbstractJdbcCall implements SimpleJdbcCallOp
return this;
}
@SuppressWarnings("unchecked")
public <T> T executeFunction(Class<T> returnType, Object... args) {
return (T) doExecute(args).get(getScalarOutParameterName());
}
@SuppressWarnings("unchecked")
public <T> T executeFunction(Class<T> returnType, Map<String, Object> args) {
@ -142,6 +146,11 @@ public class SimpleJdbcCall extends AbstractJdbcCall implements SimpleJdbcCallOp
return (T) doExecute(args).get(getScalarOutParameterName());
}
@SuppressWarnings("unchecked")
public <T> T executeObject(Class<T> returnType, Object... args) {
return (T) doExecute(args).get(getScalarOutParameterName());
}
@SuppressWarnings("unchecked")
public <T> T executeObject(Class<T> returnType, Map<String, Object> args) {
return (T) doExecute(args).get(getScalarOutParameterName());
@ -152,8 +161,8 @@ public class SimpleJdbcCall extends AbstractJdbcCall implements SimpleJdbcCallOp
return (T) doExecute(args).get(getScalarOutParameterName());
}
public Map<String, Object> execute() {
return doExecute(new HashMap<String, Object>());
public Map<String, Object> execute(Object... args) {
return doExecute(args);
}
public Map<String, Object> execute(Map<String, Object> args) {

View File

@ -101,6 +101,14 @@ public interface SimpleJdbcCallOperations {
SimpleJdbcCallOperations withoutProcedureColumnMetaDataAccess();
/**
* Execute the stored function and return the results obtained as an Object of the specified return type.
* @param returnType the type of the value to return
* @param 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.
*/
<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.
* @param returnType the type of the value to return
@ -115,6 +123,16 @@ public interface SimpleJdbcCallOperations {
*/
<T> T executeFunction(Class<T> returnType, SqlParameterSource args);
/**
* 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.
* @param returnType the type of the value to return
* @param 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.
*/
<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.
* In the case where there are multiple out parameters, the first one is returned and additional out parameters
@ -134,10 +152,12 @@ public interface SimpleJdbcCallOperations {
<T> T executeObject(Class<T> returnType, SqlParameterSource args);
/**
* Execute the stored procedure and return a map of output params, keyed by name as in parameter declarations..
* Execute the stored procedure and return a map of output params, keyed by name as in parameter declarations.
* @param 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.
* @return map of output params.
*/
Map<String, Object> execute();
Map<String, Object> execute(Object... args);
/**
* Execute the stored procedure and return a map of output params, keyed by name as in parameter declarations..

View File

@ -138,45 +138,11 @@ public class SimpleJdbcCallTests extends TestCase {
}
}
public void testAddInvoiceProcWithoutMetaData() throws Exception {
public void testAddInvoiceProcWithoutMetaDataUsingMapParamSource() throws Exception {
final int amount = 1103;
final int custid = 3;
mockDatabaseMetaData.getDatabaseProductName();
ctrlDatabaseMetaData.setReturnValue("MyDB");
mockDatabaseMetaData.getUserName();
ctrlDatabaseMetaData.setReturnValue("me");
mockDatabaseMetaData.supportsCatalogsInProcedureCalls();
ctrlDatabaseMetaData.setReturnValue(false);
mockDatabaseMetaData.supportsSchemasInProcedureCalls();
ctrlDatabaseMetaData.setReturnValue(false);
mockDatabaseMetaData.storesUpperCaseIdentifiers();
ctrlDatabaseMetaData.setReturnValue(false);
mockDatabaseMetaData.storesLowerCaseIdentifiers();
ctrlDatabaseMetaData.setReturnValue(true);
mockCallable.setObject(1, 1103, 4);
ctrlCallable.setVoidCallable();
mockCallable.setObject(2, 3, 4);
ctrlCallable.setVoidCallable();
mockCallable.registerOutParameter(3, 4);
ctrlCallable.setVoidCallable();
mockCallable.execute();
ctrlCallable.setReturnValue(false);
mockCallable.getUpdateCount();
ctrlCallable.setReturnValue(-1);
mockCallable.getObject(3);
ctrlCallable.setReturnValue(new Long(4));
if (debugEnabled) {
mockCallable.getWarnings();
ctrlCallable.setReturnValue(null);
}
mockCallable.close();
ctrlCallable.setVoidCallable();
mockConnection.prepareCall(
"{call add_invoice(?, ?, ?)}");
ctrlConnection.setReturnValue(mockCallable);
initializeAddInvoiceWithoutMetaData(false);
replay();
@ -190,105 +156,27 @@ public class SimpleJdbcCallTests extends TestCase {
assertEquals(4, newId.intValue());
}
public void testAddInvoiceProcWithMetaData() throws Exception {
public void testAddInvoiceProcWithoutMetaDataUsingArrayParams() throws Exception {
final int amount = 1103;
final int custid = 3;
MockControl ctrlResultSet = MockControl.createControl(ResultSet.class);
ResultSet mockResultSet = (ResultSet) ctrlResultSet.getMock();
mockResultSet.next();
ctrlResultSet.setReturnValue(true);
mockResultSet.getString("PROCEDURE_CAT");
ctrlResultSet.setReturnValue(null);
mockResultSet.getString("PROCEDURE_SCHEM");
ctrlResultSet.setReturnValue(null);
mockResultSet.getString("PROCEDURE_NAME");
ctrlResultSet.setReturnValue("add_invoice");
mockResultSet.next();
ctrlResultSet.setReturnValue(false);
mockResultSet.close();
ctrlResultSet.setVoidCallable();
mockResultSet.next();
ctrlResultSet.setReturnValue(true);
mockResultSet.getString("COLUMN_NAME");
ctrlResultSet.setReturnValue("amount");
mockResultSet.getInt("COLUMN_TYPE");
ctrlResultSet.setReturnValue(1);
mockResultSet.getInt("DATA_TYPE");
ctrlResultSet.setReturnValue(4);
mockResultSet.getString("TYPE_NAME");
ctrlResultSet.setReturnValue(null);
mockResultSet.getBoolean("NULLABLE");
ctrlResultSet.setReturnValue(false);
mockResultSet.next();
ctrlResultSet.setReturnValue(true);
mockResultSet.getString("COLUMN_NAME");
ctrlResultSet.setReturnValue("custid");
mockResultSet.getInt("COLUMN_TYPE");
ctrlResultSet.setReturnValue(1);
mockResultSet.getInt("DATA_TYPE");
ctrlResultSet.setReturnValue(4);
mockResultSet.getString("TYPE_NAME");
ctrlResultSet.setReturnValue(null);
mockResultSet.getBoolean("NULLABLE");
ctrlResultSet.setReturnValue(false);
mockResultSet.next();
ctrlResultSet.setReturnValue(true);
mockResultSet.getString("COLUMN_NAME");
ctrlResultSet.setReturnValue("newid");
mockResultSet.getInt("COLUMN_TYPE");
ctrlResultSet.setReturnValue(4);
mockResultSet.getInt("DATA_TYPE");
ctrlResultSet.setReturnValue(4);
mockResultSet.getString("TYPE_NAME");
ctrlResultSet.setReturnValue(null);
mockResultSet.getBoolean("NULLABLE");
ctrlResultSet.setReturnValue(false);
mockResultSet.next();
ctrlResultSet.setReturnValue(false);
mockResultSet.close();
ctrlResultSet.setVoidCallable();
initializeAddInvoiceWithoutMetaData(false);
replay();
mockDatabaseMetaData.getDatabaseProductName();
ctrlDatabaseMetaData.setReturnValue("Oracle");
mockDatabaseMetaData.getUserName();
ctrlDatabaseMetaData.setReturnValue("ME");
mockDatabaseMetaData.supportsCatalogsInProcedureCalls();
ctrlDatabaseMetaData.setReturnValue(false);
mockDatabaseMetaData.supportsSchemasInProcedureCalls();
ctrlDatabaseMetaData.setReturnValue(false);
mockDatabaseMetaData.storesUpperCaseIdentifiers();
ctrlDatabaseMetaData.setReturnValue(true);
mockDatabaseMetaData.storesLowerCaseIdentifiers();
ctrlDatabaseMetaData.setReturnValue(false);
mockDatabaseMetaData.getProcedures("", "ME", "ADD_INVOICE");
ctrlDatabaseMetaData.setReturnValue(mockResultSet);
mockDatabaseMetaData.getProcedureColumns("", "ME", "ADD_INVOICE", null);
ctrlDatabaseMetaData.setReturnValue(mockResultSet);
SimpleJdbcCall adder = new SimpleJdbcCall(mockDataSource).withProcedureName("add_invoice");
adder.declareParameters(new SqlParameter("amount", Types.INTEGER),
new SqlParameter("custid", Types.INTEGER),
new SqlOutParameter("newid", Types.INTEGER));
Number newId = adder.executeObject(Number.class, amount, custid);
assertEquals(4, newId.intValue());
}
mockCallable.setObject(1, 1103, 4);
ctrlCallable.setVoidCallable();
mockCallable.setObject(2, 3, 4);
ctrlCallable.setVoidCallable();
mockCallable.registerOutParameter(3, 4);
ctrlCallable.setVoidCallable();
mockCallable.execute();
ctrlCallable.setReturnValue(false);
mockCallable.getUpdateCount();
ctrlCallable.setReturnValue(-1);
mockCallable.getObject(3);
ctrlCallable.setReturnValue(new Long(4));
if (debugEnabled) {
mockCallable.getWarnings();
ctrlCallable.setReturnValue(null);
}
mockCallable.close();
ctrlCallable.setVoidCallable();
public void testAddInvoiceProcWithMetaDataUsingMapParamSource() throws Exception {
final int amount = 1103;
final int custid = 3;
mockConnection.prepareCall(
"{call ADD_INVOICE(?, ?, ?)}");
ctrlConnection.setReturnValue(mockCallable);
MockControl ctrlResultSet = initializeAddInvoiceWithMetaData(false);
ctrlResultSet.replay();
replay();
@ -302,45 +190,27 @@ public class SimpleJdbcCallTests extends TestCase {
ctrlResultSet.verify();
}
public void testAddInvoiceFuncWithoutMetaData() throws Exception {
public void testAddInvoiceProcWithMetaDataUsingArrayParams() throws Exception {
final int amount = 1103;
final int custid = 3;
mockDatabaseMetaData.getDatabaseProductName();
ctrlDatabaseMetaData.setReturnValue("MyDB");
mockDatabaseMetaData.getUserName();
ctrlDatabaseMetaData.setReturnValue("me");
mockDatabaseMetaData.supportsCatalogsInProcedureCalls();
ctrlDatabaseMetaData.setReturnValue(false);
mockDatabaseMetaData.supportsSchemasInProcedureCalls();
ctrlDatabaseMetaData.setReturnValue(false);
mockDatabaseMetaData.storesUpperCaseIdentifiers();
ctrlDatabaseMetaData.setReturnValue(false);
mockDatabaseMetaData.storesLowerCaseIdentifiers();
ctrlDatabaseMetaData.setReturnValue(true);
MockControl ctrlResultSet = initializeAddInvoiceWithMetaData(false);
mockCallable.registerOutParameter(1, 4);
ctrlCallable.setVoidCallable();
mockCallable.setObject(2, 1103, 4);
ctrlCallable.setVoidCallable();
mockCallable.setObject(3, 3, 4);
ctrlCallable.setVoidCallable();
mockCallable.execute();
ctrlCallable.setReturnValue(false);
mockCallable.getUpdateCount();
ctrlCallable.setReturnValue(-1);
mockCallable.getObject(1);
ctrlCallable.setReturnValue(new Long(4));
if (debugEnabled) {
mockCallable.getWarnings();
ctrlCallable.setReturnValue(null);
}
mockCallable.close();
ctrlCallable.setVoidCallable();
ctrlResultSet.replay();
replay();
mockConnection.prepareCall(
"{? = call add_invoice(?, ?)}");
ctrlConnection.setReturnValue(mockCallable);
SimpleJdbcCall adder = new SimpleJdbcCall(mockDataSource).withProcedureName("add_invoice");
Number newId = adder.executeObject(Number.class, amount, custid);
assertEquals(4, newId.intValue());
ctrlResultSet.verify();
}
public void testAddInvoiceFuncWithoutMetaDataUsingMapParamSource() throws Exception {
final int amount = 1103;
final int custid = 3;
initializeAddInvoiceWithoutMetaData(true);
replay();
@ -354,10 +224,117 @@ public class SimpleJdbcCallTests extends TestCase {
assertEquals(4, newId.intValue());
}
public void testAddInvoiceFuncWithMetaData() throws Exception {
public void testAddInvoiceFuncWithoutMetaDataUsingArrayParams() throws Exception {
final int amount = 1103;
final int custid = 3;
initializeAddInvoiceWithoutMetaData(true);
replay();
SimpleJdbcCall adder = new SimpleJdbcCall(mockDataSource).withFunctionName("add_invoice");
adder.declareParameters(new SqlOutParameter("return", Types.INTEGER),
new SqlParameter("amount", Types.INTEGER),
new SqlParameter("custid", Types.INTEGER));
Number newId = adder.executeFunction(Number.class, amount, custid);
assertEquals(4, newId.intValue());
}
public void testAddInvoiceFuncWithMetaDataUsingMapParamSource() throws Exception {
final int amount = 1103;
final int custid = 3;
MockControl ctrlResultSet = initializeAddInvoiceWithMetaData(true);
ctrlResultSet.replay();
replay();
SimpleJdbcCall adder = new SimpleJdbcCall(mockDataSource).withFunctionName("add_invoice");
Number newId = adder.executeFunction(Number.class, new MapSqlParameterSource()
.addValue("amount", amount)
.addValue("custid", custid));
assertEquals(4, newId.intValue());
ctrlResultSet.verify();
}
public void testAddInvoiceFuncWithMetaDataUsingArrayParams() throws Exception {
final int amount = 1103;
final int custid = 3;
MockControl ctrlResultSet = initializeAddInvoiceWithMetaData(true);
ctrlResultSet.replay();
replay();
SimpleJdbcCall adder = new SimpleJdbcCall(mockDataSource).withFunctionName("add_invoice");
Number newId = adder.executeFunction(Number.class, amount, custid);
assertEquals(4, newId.intValue());
ctrlResultSet.verify();
}
private void initializeAddInvoiceWithoutMetaData(boolean isFunction) throws SQLException {
mockDatabaseMetaData.getDatabaseProductName();
ctrlDatabaseMetaData.setReturnValue("MyDB");
mockDatabaseMetaData.getUserName();
ctrlDatabaseMetaData.setReturnValue("me");
mockDatabaseMetaData.supportsCatalogsInProcedureCalls();
ctrlDatabaseMetaData.setReturnValue(false);
mockDatabaseMetaData.supportsSchemasInProcedureCalls();
ctrlDatabaseMetaData.setReturnValue(false);
mockDatabaseMetaData.storesUpperCaseIdentifiers();
ctrlDatabaseMetaData.setReturnValue(false);
mockDatabaseMetaData.storesLowerCaseIdentifiers();
ctrlDatabaseMetaData.setReturnValue(true);
if (isFunction) {
mockCallable.registerOutParameter(1, 4);
ctrlCallable.setVoidCallable();
mockCallable.setObject(2, 1103, 4);
ctrlCallable.setVoidCallable();
mockCallable.setObject(3, 3, 4);
ctrlCallable.setVoidCallable();
}
else {
mockCallable.setObject(1, 1103, 4);
ctrlCallable.setVoidCallable();
mockCallable.setObject(2, 3, 4);
ctrlCallable.setVoidCallable();
mockCallable.registerOutParameter(3, 4);
ctrlCallable.setVoidCallable();
}
mockCallable.execute();
ctrlCallable.setReturnValue(false);
mockCallable.getUpdateCount();
ctrlCallable.setReturnValue(-1);
if (isFunction) {
mockCallable.getObject(1);
}
else {
mockCallable.getObject(3);
}
ctrlCallable.setReturnValue(new Long(4));
if (debugEnabled) {
mockCallable.getWarnings();
ctrlCallable.setReturnValue(null);
}
mockCallable.close();
ctrlCallable.setVoidCallable();
if (isFunction) {
mockConnection.prepareCall(
"{? = call add_invoice(?, ?)}");
ctrlConnection.setReturnValue(mockCallable);
}
else {
mockConnection.prepareCall(
"{call add_invoice(?, ?, ?)}");
ctrlConnection.setReturnValue(mockCallable);
}
}
private MockControl initializeAddInvoiceWithMetaData(boolean isFunction) throws SQLException {
MockControl ctrlResultSet = MockControl.createControl(ResultSet.class);
ResultSet mockResultSet = (ResultSet) ctrlResultSet.getMock();
mockResultSet.next();
@ -374,10 +351,18 @@ public class SimpleJdbcCallTests extends TestCase {
ctrlResultSet.setVoidCallable();
mockResultSet.next();
ctrlResultSet.setReturnValue(true);
mockResultSet.getString("COLUMN_NAME");
ctrlResultSet.setReturnValue(null);
mockResultSet.getInt("COLUMN_TYPE");
ctrlResultSet.setReturnValue(5);
if (isFunction) {
mockResultSet.getString("COLUMN_NAME");
ctrlResultSet.setReturnValue(null);
mockResultSet.getInt("COLUMN_TYPE");
ctrlResultSet.setReturnValue(5);
}
else {
mockResultSet.getString("COLUMN_NAME");
ctrlResultSet.setReturnValue("amount");
mockResultSet.getInt("COLUMN_TYPE");
ctrlResultSet.setReturnValue(1);
}
mockResultSet.getInt("DATA_TYPE");
ctrlResultSet.setReturnValue(4);
mockResultSet.getString("TYPE_NAME");
@ -386,10 +371,18 @@ public class SimpleJdbcCallTests extends TestCase {
ctrlResultSet.setReturnValue(false);
mockResultSet.next();
ctrlResultSet.setReturnValue(true);
mockResultSet.getString("COLUMN_NAME");
ctrlResultSet.setReturnValue("amount");
mockResultSet.getInt("COLUMN_TYPE");
ctrlResultSet.setReturnValue(1);
if (isFunction) {
mockResultSet.getString("COLUMN_NAME");
ctrlResultSet.setReturnValue("amount");
mockResultSet.getInt("COLUMN_TYPE");
ctrlResultSet.setReturnValue(1);
}
else {
mockResultSet.getString("COLUMN_NAME");
ctrlResultSet.setReturnValue("custid");
mockResultSet.getInt("COLUMN_TYPE");
ctrlResultSet.setReturnValue(1);
}
mockResultSet.getInt("DATA_TYPE");
ctrlResultSet.setReturnValue(4);
mockResultSet.getString("TYPE_NAME");
@ -398,10 +391,18 @@ public class SimpleJdbcCallTests extends TestCase {
ctrlResultSet.setReturnValue(false);
mockResultSet.next();
ctrlResultSet.setReturnValue(true);
mockResultSet.getString("COLUMN_NAME");
ctrlResultSet.setReturnValue("custid");
mockResultSet.getInt("COLUMN_TYPE");
ctrlResultSet.setReturnValue(1);
if (isFunction) {
mockResultSet.getString("COLUMN_NAME");
ctrlResultSet.setReturnValue("custid");
mockResultSet.getInt("COLUMN_TYPE");
ctrlResultSet.setReturnValue(1);
}
else {
mockResultSet.getString("COLUMN_NAME");
ctrlResultSet.setReturnValue("newid");
mockResultSet.getInt("COLUMN_TYPE");
ctrlResultSet.setReturnValue(4);
}
mockResultSet.getInt("DATA_TYPE");
ctrlResultSet.setReturnValue(4);
mockResultSet.getString("TYPE_NAME");
@ -413,7 +414,6 @@ public class SimpleJdbcCallTests extends TestCase {
mockResultSet.close();
ctrlResultSet.setVoidCallable();
mockDatabaseMetaData.getDatabaseProductName();
ctrlDatabaseMetaData.setReturnValue("Oracle");
mockDatabaseMetaData.getUserName();
@ -431,18 +431,34 @@ public class SimpleJdbcCallTests extends TestCase {
mockDatabaseMetaData.getProcedureColumns("", "ME", "ADD_INVOICE", null);
ctrlDatabaseMetaData.setReturnValue(mockResultSet);
mockCallable.registerOutParameter(1, 4);
ctrlCallable.setVoidCallable();
mockCallable.setObject(2, 1103, 4);
ctrlCallable.setVoidCallable();
mockCallable.setObject(3, 3, 4);
ctrlCallable.setVoidCallable();
if (isFunction) {
mockCallable.registerOutParameter(1, 4);
ctrlCallable.setVoidCallable();
mockCallable.setObject(2, 1103, 4);
ctrlCallable.setVoidCallable();
mockCallable.setObject(3, 3, 4);
ctrlCallable.setVoidCallable();
}
else {
mockCallable.setObject(1, 1103, 4);
ctrlCallable.setVoidCallable();
mockCallable.setObject(2, 3, 4);
ctrlCallable.setVoidCallable();
mockCallable.registerOutParameter(3, 4);
ctrlCallable.setVoidCallable();
}
mockCallable.execute();
ctrlCallable.setReturnValue(false);
mockCallable.getUpdateCount();
ctrlCallable.setReturnValue(-1);
mockCallable.getObject(1);
ctrlCallable.setReturnValue(new Long(4));
if (isFunction) {
mockCallable.getObject(1);
ctrlCallable.setReturnValue(new Long(4));
}
else {
mockCallable.getObject(3);
ctrlCallable.setReturnValue(new Long(4));
}
if (debugEnabled) {
mockCallable.getWarnings();
ctrlCallable.setReturnValue(null);
@ -450,20 +466,17 @@ public class SimpleJdbcCallTests extends TestCase {
mockCallable.close();
ctrlCallable.setVoidCallable();
mockConnection.prepareCall(
"{? = call ADD_INVOICE(?, ?)}");
ctrlConnection.setReturnValue(mockCallable);
ctrlResultSet.replay();
replay();
SimpleJdbcCall adder = new SimpleJdbcCall(mockDataSource).withFunctionName("add_invoice");
Number newId = adder.executeFunction(Number.class, new MapSqlParameterSource()
.addValue("amount", amount)
.addValue("custid", custid));
assertEquals(4, newId.intValue());
ctrlResultSet.verify();
if (isFunction) {
mockConnection.prepareCall(
"{? = call ADD_INVOICE(?, ?)}");
ctrlConnection.setReturnValue(mockCallable);
}
else {
mockConnection.prepareCall(
"{call ADD_INVOICE(?, ?, ?)}");
ctrlConnection.setReturnValue(mockCallable);
}
return ctrlResultSet;
}
}