fixed problem retrieving out parameter for function call with MS SQL Server (SPR-5435)

This commit is contained in:
Thomas Risberg 2009-05-28 23:25:25 +00:00
parent 1a790688f4
commit b1c6ae99c4
1 changed files with 11 additions and 6 deletions

View File

@ -64,8 +64,11 @@ public class CallMetaDataContext {
/** List of SqlParameter objects to be used in call execution */ /** List of SqlParameter objects to be used in call execution */
private List<SqlParameter> callParameters = new ArrayList<SqlParameter>(); private List<SqlParameter> callParameters = new ArrayList<SqlParameter>();
/** name to use for the return value in the output map */ /** Default name to use for the return value in the output map */
private String functionReturnName = "return"; private String defaultFunctionReturnName = "return";
/** Actual name to use for the return value in the output map */
private String actualFunctionReturnName = null;
/** Set of in parameter names to exclude use for any not listed */ /** Set of in parameter names to exclude use for any not listed */
private Set<String> limitedInParameterNames = new HashSet<String>(); private Set<String> limitedInParameterNames = new HashSet<String>();
@ -90,14 +93,14 @@ public class CallMetaDataContext {
* Specify the name used for the return value of the function. * Specify the name used for the return value of the function.
*/ */
public void setFunctionReturnName(String functionReturnName) { public void setFunctionReturnName(String functionReturnName) {
this.functionReturnName = functionReturnName; this.actualFunctionReturnName = functionReturnName;
} }
/** /**
* Get the name used for the return value of the function. * Get the name used for the return value of the function.
*/ */
public String getFunctionReturnName() { public String getFunctionReturnName() {
return this.functionReturnName; return this.actualFunctionReturnName != null ? this.actualFunctionReturnName : this.defaultFunctionReturnName;
} }
/** /**
@ -240,7 +243,7 @@ public class CallMetaDataContext {
*/ */
public String getScalarOutParameterName() { public String getScalarOutParameterName() {
if (isFunction()) { if (isFunction()) {
return this.functionReturnName; return getFunctionReturnName();
} }
else { else {
if (this.outParameterNames.size() > 1) { if (this.outParameterNames.size() > 1) {
@ -377,8 +380,10 @@ public class CallMetaDataContext {
( meta.getParameterName() == null || meta.getParameterName().length() < 1 ) ? ( meta.getParameterName() == null || meta.getParameterName().length() < 1 ) ?
this.getFunctionReturnName() : parNameToUse; this.getFunctionReturnName() : parNameToUse;
workParameters.add(new SqlOutParameter(returnNameToUse, meta.getSqlType())); workParameters.add(new SqlOutParameter(returnNameToUse, meta.getSqlType()));
if (this.isFunction()) if (this.isFunction()) {
this.setFunctionReturnName(returnNameToUse);
outParameterNames.add(returnNameToUse); outParameterNames.add(returnNameToUse);
}
if (logger.isDebugEnabled()) { if (logger.isDebugEnabled()) {
logger.debug("Added metadata return parameter for: " + returnNameToUse); logger.debug("Added metadata return parameter for: " + returnNameToUse);
} }