- 
                Notifications
    You must be signed in to change notification settings 
- Fork 38.8k
Closed as not planned
Closed as not planned
Copy link
Labels
has: votes-jiraIssues migrated from JIRA with more than 10 votes at the time of importIssues migrated from JIRA with more than 10 votes at the time of importin: dataIssues in data modules (jdbc, orm, oxm, tx)Issues in data modules (jdbc, orm, oxm, tx)status: declinedA suggestion or change that we don't feel we should currently applyA suggestion or change that we don't feel we should currently applytype: enhancementA general enhancementA general enhancement
Description
Mike Calmus opened SPR-4406 and commented
Named parameters have been added for some operations, but the execution of a CallableStatement does not support named parameters.
The following code block from CallableStatementFactory.CallableStatementCreatorImpl would be affected or need to be extended:
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++;
	}
}
Issue Links:
- Support for named parameters in SimpleJdbcCall[SPR-12801] #17398 Support for named parameters in SimpleJdbcCall
- StoredProcedure enhancement to allow parameters to be optional [SPR-3510] #8193 StoredProcedure enhancement to allow parameters to be optional
10 votes, 8 watchers
Metadata
Metadata
Assignees
Labels
has: votes-jiraIssues migrated from JIRA with more than 10 votes at the time of importIssues migrated from JIRA with more than 10 votes at the time of importin: dataIssues in data modules (jdbc, orm, oxm, tx)Issues in data modules (jdbc, orm, oxm, tx)status: declinedA suggestion or change that we don't feel we should currently applyA suggestion or change that we don't feel we should currently applytype: enhancementA general enhancementA general enhancement