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"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with 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 * Get the name of the single out parameter for this call.
* the first one is returned. * If there are multiple parameters, the name of the first one will be returned.
*/ */
public String getScalarOutParameterName() { public String getScalarOutParameterName() {
if (isFunction()) { 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() { public List<SqlParameter> getCallParameters() {
return this.callParameters; 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 * @param dataSource the DataSource used to retrieve metadata
*/ */
public void initializeMetaData(DataSource dataSource) { 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 * Process the list of parameters provided, and if procedure column metadata is used,
* parameters will be matched against the metadata information and any missing ones will * the parameters will be matched against the metadata information and any missing
* be automatically included * ones will be automatically included.
* @param parameters the list of parameters to use as a base * @param parameters the list of parameters to use as a base
*/ */
public void processParameters(List<SqlParameter> parameters) { 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) { protected List<SqlParameter> reconcileParameters(List<SqlParameter> parameters) {
final List<SqlParameter> declaredReturnParameters = new ArrayList<SqlParameter>(); final List<SqlParameter> declaredReturnParameters = new ArrayList<SqlParameter>();
@ -289,7 +289,7 @@ public class CallMetaDataContext {
List<String> outParameterNames = new ArrayList<String>(); List<String> outParameterNames = new ArrayList<String>();
List<String> metaDataParameterNames = 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()) { for (CallParameterMetaData meta : this.metaDataProvider.getCallParameterMetaData()) {
if (meta.getParameterType() != DatabaseMetaData.procedureColumnReturn) { if (meta.getParameterType() != DatabaseMetaData.procedureColumnReturn) {
metaDataParameterNames.add(meta.getParameterName().toLowerCase()); metaDataParameterNames.add(meta.getParameterName().toLowerCase());
@ -424,7 +424,6 @@ public class CallMetaDataContext {
} }
return workParameters; return workParameters;
} }
/** /**
@ -565,8 +564,8 @@ public class CallMetaDataContext {
public String createCallString() { public String createCallString() {
String callString; String callString;
int parameterCount = 0; int parameterCount = 0;
String catalogNameToUse = null; String catalogNameToUse;
String schemaNameToUse = null; String schemaNameToUse;
// For Oracle where catalogs are not supported we need to reverse the schema name // 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 // 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"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with 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) public void initializeWithProcedureColumnMetaData(DatabaseMetaData databaseMetaData, String catalogName,
throws SQLException { String schemaName, String procedureName) throws SQLException {
this.procedureColumnMetaDataUsed = true; this.procedureColumnMetaDataUsed = true;
processProcedureColumns(databaseMetaData, catalogName, schemaName, procedureName); processProcedureColumns(databaseMetaData, catalogName, schemaName, procedureName);
} }
public List<CallParameterMetaData> getCallParameterMetaData() { public List<CallParameterMetaData> getCallParameterMetaData() {
return callParameterMetaData; return this.callParameterMetaData;
} }
public String procedureNameToUse(String procedureName) { public String procedureNameToUse(String procedureName) {
if (procedureName == null) if (procedureName == null) {
return null; return null;
else if (isStoresUpperCaseIdentifiers()) }
else if (isStoresUpperCaseIdentifiers()) {
return procedureName.toUpperCase(); return procedureName.toUpperCase();
else if(isStoresLowerCaseIdentifiers()) }
else if(isStoresLowerCaseIdentifiers()) {
return procedureName.toLowerCase(); return procedureName.toLowerCase();
else }
else {
return procedureName; return procedureName;
}
} }
public String catalogNameToUse(String catalogName) { public String catalogNameToUse(String catalogName) {
if (catalogName == null) if (catalogName == null) {
return null; return null;
else if (isStoresUpperCaseIdentifiers()) }
else if (isStoresUpperCaseIdentifiers()) {
return catalogName.toUpperCase(); return catalogName.toUpperCase();
else if(isStoresLowerCaseIdentifiers()) }
else if(isStoresLowerCaseIdentifiers()) {
return catalogName.toLowerCase(); return catalogName.toLowerCase();
else }
return catalogName; else {
return catalogName;
}
} }
public String schemaNameToUse(String schemaName) { public String schemaNameToUse(String schemaName) {
if (schemaName == null) if (schemaName == null) {
return null; return null;
else if (isStoresUpperCaseIdentifiers()) }
else if (isStoresUpperCaseIdentifiers()) {
return schemaName.toUpperCase(); return schemaName.toUpperCase();
else if(isStoresLowerCaseIdentifiers()) }
else if(isStoresLowerCaseIdentifiers()) {
return schemaName.toLowerCase(); return schemaName.toLowerCase();
else }
return schemaName; else {
return schemaName;
}
} }
public String metaDataCatalogNameToUse(String catalogName) { 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"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with 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. * Add a declared parameter to the list of parameters for the call.
* Only parameters declared as <code>SqlParameter</code> and <code>SqlInOutParameter</code> * 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 * which for backwards compatibility reasons allows input values to be provided for parameters declared
* as <code>SqlOutParameter</code>. * as <code>SqlOutParameter</code>.
* @param parameter the {@link SqlParameter} to add * @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() { public String getCallString() {
return this.callString; 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) { public void setAccessCallParameterMetaData(boolean accessCallParameterMetaData) {
this.callMetaDataContext.setAccessCallParameterMetaData(accessCallParameterMetaData); this.callMetaDataContext.setAccessCallParameterMetaData(accessCallParameterMetaData);
@ -267,17 +267,14 @@ public abstract class AbstractJdbcCall {
if (getProcedureName() == null) { if (getProcedureName() == null) {
throw new InvalidDataAccessApiUsageException("Procedure or Function name is required"); throw new InvalidDataAccessApiUsageException("Procedure or Function name is required");
} }
try { try {
this.jdbcTemplate.afterPropertiesSet(); this.jdbcTemplate.afterPropertiesSet();
} }
catch (IllegalArgumentException ex) { catch (IllegalArgumentException ex) {
throw new InvalidDataAccessApiUsageException(ex.getMessage()); throw new InvalidDataAccessApiUsageException(ex.getMessage());
} }
compileInternal(); compileInternal();
this.compiled = true; this.compiled = true;
if (logger.isDebugEnabled()) { if (logger.isDebugEnabled()) {
logger.debug("SqlCall for " + (isFunction() ? "function" : "procedure") + " [" + getProcedureName() + "] compiled"); logger.debug("SqlCall for " + (isFunction() ? "function" : "procedure") + " [" + getProcedureName() + "] compiled");
} }