if (this.inParameterMapper != null) {
this.inParameters = this.inParameterMapper.createMap(con);
}
else {
if (this.inParameters == null) {
throw new InvalidDataAccessApiUsageException(
"A ParameterMapper or a Map of parameters must be provided");
}
}
CallableStatement cs = null;
if (resultSetType == ResultSet.TYPE_FORWARD_ONLY && !updatableResults) {
cs = con.prepareCall(callString);
}
else {
cs = con.prepareCall(callString, resultSetType,
updatableResults ? ResultSet.CONCUR_UPDATABLE : ResultSet.CONCUR_READ_ONLY);
}
// Determine CallabeStatement to pass to custom types.
CallableStatement csToUse = cs;
if (nativeJdbcExtractor != null) {
csToUse = nativeJdbcExtractor.getNativeCallableStatement(cs);
}
int sqlColIndx = 1;
for (int i = 0; i < declaredParameters.size(); i++) {
SqlParameter declaredParameter = (SqlParameter) declaredParameters.get(i);
if (!declaredParameter.isResultsParameter()) {
// So, it's a call parameter - part of the call string.
// Get the value - it may still be null.
Object inValue = this.inParameters.get(declaredParameter.getName());
if (declaredParameter instanceof ResultSetSupportingSqlParameter) {
// It's an output parameter: SqlReturnResultSet parameters already excluded.
// It need not (but may be) supplied by the caller.
if (declaredParameter instanceof SqlOutParameter) {
if (declaredParameter.getTypeName() != null) {
cs.registerOutParameter(sqlColIndx, declaredParameter.getSqlType(), declaredParameter.getTypeName());
}
else {
if (declaredParameter.getScale() != null) {
cs.registerOutParameter(sqlColIndx, declaredParameter.getSqlType(), declaredParameter.getScale().intValue());
}
else {
cs.registerOutParameter(sqlColIndx, declaredParameter.getSqlType());
}
}
if ((declaredParameter).isInputValueProvided() || inValue != null) {
StatementCreatorUtils.setParameterValue(csToUse, sqlColIndx, declaredParameter, inValue);
}
}
}
else {
// It's an input parameter- must be supplied by the caller.
if (!this.inParameters.containsKey(declaredParameter.getName())) {
throw new InvalidDataAccessApiUsageException(
"Required input parameter '" + declaredParameter.getName() + "' is missing");
}
StatementCreatorUtils.setParameterValue(csToUse, sqlColIndx, declaredParameter, inValue);
}
sqlColIndx++;