use of org.springframework.jdbc.core.CallableStatementCreatorFactory in project spring-framework by spring-projects.
the class AbstractJdbcCall method compileInternal.
/**
* Delegate method to perform the actual compilation.
* <p>Subclasses can override this template method to perform their own compilation.
* Invoked after this base class's compilation is complete.
*/
protected void compileInternal() {
this.callMetaDataContext.initializeMetaData(getJdbcTemplate().getDataSource());
// Iterate over the declared RowMappers and register the corresponding SqlParameter
for (Map.Entry<String, RowMapper<?>> entry : this.declaredRowMappers.entrySet()) {
SqlParameter resultSetParameter = this.callMetaDataContext.createReturnResultSetParameter(entry.getKey(), entry.getValue());
this.declaredParameters.add(resultSetParameter);
}
this.callMetaDataContext.processParameters(this.declaredParameters);
this.callString = this.callMetaDataContext.createCallString();
if (logger.isDebugEnabled()) {
logger.debug("Compiled stored procedure. Call string is [" + this.callString + "]");
}
this.callableStatementFactory = new CallableStatementCreatorFactory(getCallString(), this.callMetaDataContext.getCallParameters());
onCompileInternal();
}
use of org.springframework.jdbc.core.CallableStatementCreatorFactory in project spring-framework by spring-projects.
the class SqlCall method compileInternal.
/**
* Overridden method to configure the CallableStatementCreatorFactory
* based on our declared parameters.
* @see RdbmsOperation#compileInternal()
*/
@Override
protected final void compileInternal() {
if (isSqlReadyForUse()) {
this.callString = getSql();
} else {
List<SqlParameter> parameters = getDeclaredParameters();
int parameterCount = 0;
if (isFunction()) {
this.callString = "{? = call " + getSql() + "(";
parameterCount = -1;
} else {
this.callString = "{call " + getSql() + "(";
}
for (SqlParameter parameter : parameters) {
if (!(parameter.isResultsParameter())) {
if (parameterCount > 0) {
this.callString += ", ";
}
if (parameterCount >= 0) {
this.callString += "?";
}
parameterCount++;
}
}
this.callString += ")}";
}
if (logger.isDebugEnabled()) {
logger.debug("Compiled stored procedure. Call string is [" + getCallString() + "]");
}
this.callableStatementFactory = new CallableStatementCreatorFactory(getCallString(), getDeclaredParameters());
this.callableStatementFactory.setResultSetType(getResultSetType());
this.callableStatementFactory.setUpdatableResults(isUpdatableResults());
onCompileInternal();
}
Aggregations