polishing

This commit is contained in:
Juergen Hoeller 2011-12-11 23:07:07 +00:00
parent dd7950638d
commit 1141a1d610
3 changed files with 46 additions and 38 deletions

View File

@ -1,5 +1,5 @@
/*
* Copyright 2002-2010 the original author or authors.
* Copyright 2002-2011 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -239,8 +239,8 @@ public class CallMetaDataContext {
}
/**
* Get the name of the single out parameter for this call. If there are multiple parameters then the name of
* the first one is returned.
* Get the name of the single out parameter for this call.
* If there are multiple parameters, the name of the first one will be returned.
*/
public String getScalarOutParameterName() {
if (isFunction()) {
@ -255,14 +255,14 @@ public class CallMetaDataContext {
}
/**
* Get the List of SqlParameter objects to be used in call execution
* Get the List of SqlParameter objects to be used in call execution.
*/
public List<SqlParameter> getCallParameters() {
return this.callParameters;
}
/**
* Initialize this class with metadata from the database
* Initialize this class with metadata from the database.
* @param dataSource the DataSource used to retrieve metadata
*/
public void initializeMetaData(DataSource dataSource) {
@ -270,9 +270,9 @@ public class CallMetaDataContext {
}
/**
* Process the list of parameters provided and if procedure column metadata is used the
* parameters will be matched against the metadata information and any missing ones will
* be automatically included
* Process the list of parameters provided, and if procedure column metadata is used,
* the parameters will be matched against the metadata information and any missing
* ones will be automatically included.
* @param parameters the list of parameters to use as a base
*/
public void processParameters(List<SqlParameter> parameters) {
@ -280,7 +280,7 @@ public class CallMetaDataContext {
}
/**
* Reconcile the provided parameters with available metadata and add new ones where appropriate
* Reconcile the provided parameters with available metadata and add new ones where appropriate.
*/
protected List<SqlParameter> reconcileParameters(List<SqlParameter> parameters) {
final List<SqlParameter> declaredReturnParameters = new ArrayList<SqlParameter>();
@ -289,7 +289,7 @@ public class CallMetaDataContext {
List<String> outParameterNames = new ArrayList<String>();
List<String> metaDataParameterNames = new ArrayList<String>();
// get the names of the meta data parameters
// Get the names of the meta data parameters
for (CallParameterMetaData meta : this.metaDataProvider.getCallParameterMetaData()) {
if (meta.getParameterType() != DatabaseMetaData.procedureColumnReturn) {
metaDataParameterNames.add(meta.getParameterName().toLowerCase());
@ -424,7 +424,6 @@ public class CallMetaDataContext {
}
return workParameters;
}
/**
@ -565,8 +564,8 @@ public class CallMetaDataContext {
public String createCallString() {
String callString;
int parameterCount = 0;
String catalogNameToUse = null;
String schemaNameToUse = null;
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

View File

@ -1,5 +1,5 @@
/*
* Copyright 2002-2008 the original author or authors.
* Copyright 2002-2011 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -95,48 +95,60 @@ public class GenericCallMetaDataProvider implements CallMetaDataProvider {
}
}
public void initializeWithProcedureColumnMetaData(DatabaseMetaData databaseMetaData, String catalogName, String schemaName, String procedureName)
throws SQLException {
public void initializeWithProcedureColumnMetaData(DatabaseMetaData databaseMetaData, String catalogName,
String schemaName, String procedureName) throws SQLException {
this.procedureColumnMetaDataUsed = true;
processProcedureColumns(databaseMetaData, catalogName, schemaName, procedureName);
}
public List<CallParameterMetaData> getCallParameterMetaData() {
return callParameterMetaData;
return this.callParameterMetaData;
}
public String procedureNameToUse(String procedureName) {
if (procedureName == null)
if (procedureName == null) {
return null;
else if (isStoresUpperCaseIdentifiers())
}
else if (isStoresUpperCaseIdentifiers()) {
return procedureName.toUpperCase();
else if(isStoresLowerCaseIdentifiers())
}
else if(isStoresLowerCaseIdentifiers()) {
return procedureName.toLowerCase();
else
}
else {
return procedureName;
}
}
public String catalogNameToUse(String catalogName) {
if (catalogName == null)
if (catalogName == null) {
return null;
else if (isStoresUpperCaseIdentifiers())
}
else if (isStoresUpperCaseIdentifiers()) {
return catalogName.toUpperCase();
else if(isStoresLowerCaseIdentifiers())
}
else if(isStoresLowerCaseIdentifiers()) {
return catalogName.toLowerCase();
else
return catalogName;
}
else {
return catalogName;
}
}
public String schemaNameToUse(String schemaName) {
if (schemaName == null)
if (schemaName == null) {
return null;
else if (isStoresUpperCaseIdentifiers())
}
else if (isStoresUpperCaseIdentifiers()) {
return schemaName.toUpperCase();
else if(isStoresLowerCaseIdentifiers())
}
else if(isStoresLowerCaseIdentifiers()) {
return schemaName.toLowerCase();
else
return schemaName;
}
else {
return schemaName;
}
}
public String metaDataCatalogNameToUse(String catalogName) {

View File

@ -1,5 +1,5 @@
/*
* Copyright 2002-2010 the original author or authors.
* Copyright 2002-2011 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -198,7 +198,7 @@ public abstract class AbstractJdbcCall {
/**
* Add a declared parameter to the list of parameters for the call.
* Only parameters declared as <code>SqlParameter</code> and <code>SqlInOutParameter</code>
* will be used to provide input values. This is different from the <code>StoredProcedure</code> class
* will be used to provide input values. This is different from the <code>StoredProcedure</code> class
* which for backwards compatibility reasons allows input values to be provided for parameters declared
* as <code>SqlOutParameter</code>.
* @param parameter the {@link SqlParameter} to add
@ -237,14 +237,14 @@ public abstract class AbstractJdbcCall {
}
/**
* Get the call string that should be used based on parameters and meta data
* Get the call string that should be used based on parameters and meta data.
*/
public String getCallString() {
return this.callString;
}
/**
* Specify whether the parameter metadata for the call should be used. The default is true.
* Specify whether the parameter metadata for the call should be used. The default is true.
*/
public void setAccessCallParameterMetaData(boolean accessCallParameterMetaData) {
this.callMetaDataContext.setAccessCallParameterMetaData(accessCallParameterMetaData);
@ -267,17 +267,14 @@ public abstract class AbstractJdbcCall {
if (getProcedureName() == null) {
throw new InvalidDataAccessApiUsageException("Procedure or Function name is required");
}
try {
this.jdbcTemplate.afterPropertiesSet();
}
catch (IllegalArgumentException ex) {
throw new InvalidDataAccessApiUsageException(ex.getMessage());
}
compileInternal();
this.compiled = true;
if (logger.isDebugEnabled()) {
logger.debug("SqlCall for " + (isFunction() ? "function" : "procedure") + " [" + getProcedureName() + "] compiled");
}