Java Code Examples for org.springframework.jdbc.core.SqlParameter#isResultsParameter()

The following examples show how to use org.springframework.jdbc.core.SqlParameter#isResultsParameter() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: SqlCall.java    From lams with GNU General Public License v2.0 5 votes vote down vote up
/**
 * 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());
	this.callableStatementFactory.setNativeJdbcExtractor(getJdbcTemplate().getNativeJdbcExtractor());

	onCompileInternal();
}
 
Example 2
Source File: SqlCall.java    From spring4-understanding with Apache License 2.0 5 votes vote down vote up
/**
 * 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());
	this.callableStatementFactory.setNativeJdbcExtractor(getJdbcTemplate().getNativeJdbcExtractor());

	onCompileInternal();
}
 
Example 3
Source File: SqlCall.java    From effectivejava with Apache License 2.0 5 votes vote down vote up
/**
 * 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());
	this.callableStatementFactory.setNativeJdbcExtractor(getJdbcTemplate().getNativeJdbcExtractor());

	onCompileInternal();
}
 
Example 4
Source File: CallMetaDataContext.java    From spring-analysis-note with MIT License 4 votes vote down vote up
/**
 * Build the call string based on configuration and meta-data information.
 * @return the call string to be used
 */
public String createCallString() {
	Assert.state(this.metaDataProvider != null, "No CallMetaDataProvider available");

	StringBuilder callString;
	int parameterCount = 0;
	String catalogNameToUse;
	String schemaNameToUse;

	// For Oracle where catalogs are not supported we need to reverse the schema name
	// and the catalog name since the catalog is used for the package name
	if (this.metaDataProvider.isSupportsSchemasInProcedureCalls() &&
			!this.metaDataProvider.isSupportsCatalogsInProcedureCalls()) {
		schemaNameToUse = this.metaDataProvider.catalogNameToUse(getCatalogName());
		catalogNameToUse = this.metaDataProvider.schemaNameToUse(getSchemaName());
	}
	else {
		catalogNameToUse = this.metaDataProvider.catalogNameToUse(getCatalogName());
		schemaNameToUse = this.metaDataProvider.schemaNameToUse(getSchemaName());
	}

	String procedureNameToUse = this.metaDataProvider.procedureNameToUse(getProcedureName());
	if (isFunction() || isReturnValueRequired()) {
		callString = new StringBuilder().append("{? = call ").
				append(StringUtils.hasLength(catalogNameToUse) ? catalogNameToUse + "." : "").
				append(StringUtils.hasLength(schemaNameToUse) ? schemaNameToUse + "." : "").
				append(procedureNameToUse).append("(");
		parameterCount = -1;
	}
	else {
		callString = new StringBuilder().append("{call ").
				append(StringUtils.hasLength(catalogNameToUse) ? catalogNameToUse + "." : "").
				append(StringUtils.hasLength(schemaNameToUse) ? schemaNameToUse + "." : "").
				append(procedureNameToUse).append("(");
	}

	for (SqlParameter parameter : this.callParameters) {
		if (!parameter.isResultsParameter()) {
			if (parameterCount > 0) {
				callString.append(", ");
			}
			if (parameterCount >= 0) {
				callString.append(createParameterBinding(parameter));
			}
			parameterCount++;
		}
	}
	callString.append(")}");

	return callString.toString();
}
 
Example 5
Source File: CallMetaDataContext.java    From java-technology-stack with MIT License 4 votes vote down vote up
/**
 * Build the call string based on configuration and meta-data information.
 * @return the call string to be used
 */
public String createCallString() {
	Assert.state(this.metaDataProvider != null, "No CallMetaDataProvider available");

	StringBuilder callString;
	int parameterCount = 0;
	String catalogNameToUse;
	String schemaNameToUse;

	// For Oracle where catalogs are not supported we need to reverse the schema name
	// and the catalog name since the catalog is used for the package name
	if (this.metaDataProvider.isSupportsSchemasInProcedureCalls() &&
			!this.metaDataProvider.isSupportsCatalogsInProcedureCalls()) {
		schemaNameToUse = this.metaDataProvider.catalogNameToUse(getCatalogName());
		catalogNameToUse = this.metaDataProvider.schemaNameToUse(getSchemaName());
	}
	else {
		catalogNameToUse = this.metaDataProvider.catalogNameToUse(getCatalogName());
		schemaNameToUse = this.metaDataProvider.schemaNameToUse(getSchemaName());
	}

	String procedureNameToUse = this.metaDataProvider.procedureNameToUse(getProcedureName());
	if (isFunction() || isReturnValueRequired()) {
		callString = new StringBuilder().append("{? = call ").
				append(StringUtils.hasLength(catalogNameToUse) ? catalogNameToUse + "." : "").
				append(StringUtils.hasLength(schemaNameToUse) ? schemaNameToUse + "." : "").
				append(procedureNameToUse).append("(");
		parameterCount = -1;
	}
	else {
		callString = new StringBuilder().append("{call ").
				append(StringUtils.hasLength(catalogNameToUse) ? catalogNameToUse + "." : "").
				append(StringUtils.hasLength(schemaNameToUse) ? schemaNameToUse + "." : "").
				append(procedureNameToUse).append("(");
	}

	for (SqlParameter parameter : this.callParameters) {
		if (!parameter.isResultsParameter()) {
			if (parameterCount > 0) {
				callString.append(", ");
			}
			if (parameterCount >= 0) {
				callString.append(createParameterBinding(parameter));
			}
			parameterCount++;
		}
	}
	callString.append(")}");

	return callString.toString();
}
 
Example 6
Source File: CallMetaDataContext.java    From lams with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Build the call string based on configuration and metadata information.
 * @return the call string to be used
 */
public String createCallString() {
	String callString;
	int parameterCount = 0;
	String catalogNameToUse;
	String schemaNameToUse;

	// For Oracle where catalogs are not supported we need to reverse the schema name
	// and the catalog name since the cataog is used for the package name
	if (this.metaDataProvider.isSupportsSchemasInProcedureCalls() &&
			!this.metaDataProvider.isSupportsCatalogsInProcedureCalls()) {
		schemaNameToUse = this.metaDataProvider.catalogNameToUse(getCatalogName());
		catalogNameToUse = this.metaDataProvider.schemaNameToUse(getSchemaName());
	}
	else {
		catalogNameToUse = this.metaDataProvider.catalogNameToUse(getCatalogName());
		schemaNameToUse = this.metaDataProvider.schemaNameToUse(getSchemaName());
	}
	String procedureNameToUse = this.metaDataProvider.procedureNameToUse(getProcedureName());
	if (isFunction() || isReturnValueRequired()) {
		callString = "{? = call " +
				(StringUtils.hasLength(catalogNameToUse) ? catalogNameToUse + "." : "") +
				(StringUtils.hasLength(schemaNameToUse) ? schemaNameToUse + "." : "") +
				procedureNameToUse + "(";
		parameterCount = -1;
	}
	else {
		callString = "{call " +
				(StringUtils.hasLength(catalogNameToUse) ? catalogNameToUse + "." : "") +
				(StringUtils.hasLength(schemaNameToUse) ? schemaNameToUse + "." : "") +
				procedureNameToUse + "(";
	}
	for (SqlParameter parameter : this.callParameters) {
		if (!(parameter.isResultsParameter())) {
			if (parameterCount > 0) {
				callString += ", ";
			}
			if (parameterCount >= 0) {
				callString += createParameterBinding(parameter);
			}
			parameterCount++;
		}
	}
	callString += ")}";

	return callString;
}
 
Example 7
Source File: CallMetaDataContext.java    From spring4-understanding with Apache License 2.0 4 votes vote down vote up
/**
 * Build the call string based on configuration and metadata information.
 * @return the call string to be used
 */
public String createCallString() {
	String callString;
	int parameterCount = 0;
	String catalogNameToUse;
	String schemaNameToUse;

	// For Oracle where catalogs are not supported we need to reverse the schema name
	// and the catalog name since the cataog is used for the package name
	if (this.metaDataProvider.isSupportsSchemasInProcedureCalls() &&
			!this.metaDataProvider.isSupportsCatalogsInProcedureCalls()) {
		schemaNameToUse = this.metaDataProvider.catalogNameToUse(getCatalogName());
		catalogNameToUse = this.metaDataProvider.schemaNameToUse(getSchemaName());
	}
	else {
		catalogNameToUse = this.metaDataProvider.catalogNameToUse(getCatalogName());
		schemaNameToUse = this.metaDataProvider.schemaNameToUse(getSchemaName());
	}
	String procedureNameToUse = this.metaDataProvider.procedureNameToUse(getProcedureName());
	if (isFunction() || isReturnValueRequired()) {
		callString = "{? = call " +
				(StringUtils.hasLength(catalogNameToUse) ? catalogNameToUse + "." : "") +
				(StringUtils.hasLength(schemaNameToUse) ? schemaNameToUse + "." : "") +
				procedureNameToUse + "(";
		parameterCount = -1;
	}
	else {
		callString = "{call " +
				(StringUtils.hasLength(catalogNameToUse) ? catalogNameToUse + "." : "") +
				(StringUtils.hasLength(schemaNameToUse) ? schemaNameToUse + "." : "") +
				procedureNameToUse + "(";
	}
	for (SqlParameter parameter : this.callParameters) {
		if (!(parameter.isResultsParameter())) {
			if (parameterCount > 0) {
				callString += ", ";
			}
			if (parameterCount >= 0) {
				callString += createParameterBinding(parameter);
			}
			parameterCount++;
		}
	}
	callString += ")}";

	return callString;
}
 
Example 8
Source File: CallMetaDataContext.java    From effectivejava with Apache License 2.0 4 votes vote down vote up
/**
 * Build the call string based on configuration and metadata information.
 * @return the call string to be used
 */
public String createCallString() {
	String callString;
	int parameterCount = 0;
	String catalogNameToUse;
	String schemaNameToUse;

	// For Oracle where catalogs are not supported we need to reverse the schema name
	// and the catalog name since the cataog is used for the package name
	if (this.metaDataProvider.isSupportsSchemasInProcedureCalls() &&
			!this.metaDataProvider.isSupportsCatalogsInProcedureCalls()) {
		schemaNameToUse = this.metaDataProvider.catalogNameToUse(this.getCatalogName());
		catalogNameToUse = this.metaDataProvider.schemaNameToUse(this.getSchemaName());
	}
	else {
		catalogNameToUse = this.metaDataProvider.catalogNameToUse(this.getCatalogName());
		schemaNameToUse = this.metaDataProvider.schemaNameToUse(this.getSchemaName());
	}
	String procedureNameToUse = this.metaDataProvider.procedureNameToUse(this.getProcedureName());
	if (this.isFunction() || this.isReturnValueRequired()) {
		callString = "{? = call " +
				(StringUtils.hasLength(catalogNameToUse) ? catalogNameToUse + "." : "") +
				(StringUtils.hasLength(schemaNameToUse) ? schemaNameToUse + "." : "") +
				procedureNameToUse + "(";
		parameterCount = -1;
	}
	else {
		callString = "{call " +
				(StringUtils.hasLength(catalogNameToUse) ? catalogNameToUse + "." : "") +
				(StringUtils.hasLength(schemaNameToUse) ? schemaNameToUse + "." : "") +
				procedureNameToUse + "(";
	}
	for (SqlParameter parameter : this.callParameters) {
		if (!(parameter.isResultsParameter())) {
			if (parameterCount > 0) {
				callString += ", ";
			}
			if (parameterCount >= 0) {
				callString += "?";
			}
			parameterCount++;
		}
	}
	callString += ")}";

	return callString;
}