|
|
|
|
@ -1,5 +1,5 @@
@@ -1,5 +1,5 @@
|
|
|
|
|
/* |
|
|
|
|
* Copyright 2002-2017 the original author or authors. |
|
|
|
|
* Copyright 2002-2018 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. |
|
|
|
|
@ -20,7 +20,6 @@ import java.util.ArrayList;
@@ -20,7 +20,6 @@ import java.util.ArrayList;
|
|
|
|
|
import java.util.Collection; |
|
|
|
|
import java.util.HashSet; |
|
|
|
|
import java.util.Iterator; |
|
|
|
|
import java.util.LinkedList; |
|
|
|
|
import java.util.List; |
|
|
|
|
import java.util.Map; |
|
|
|
|
import java.util.Set; |
|
|
|
|
@ -232,7 +231,6 @@ public abstract class NamedParameterUtils {
@@ -232,7 +231,6 @@ public abstract class NamedParameterUtils {
|
|
|
|
|
// character sequence ending comment or quote not found
|
|
|
|
|
return statement.length; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
return position; |
|
|
|
|
@ -257,8 +255,11 @@ public abstract class NamedParameterUtils {
@@ -257,8 +255,11 @@ public abstract class NamedParameterUtils {
|
|
|
|
|
*/ |
|
|
|
|
public static String substituteNamedParameters(ParsedSql parsedSql, SqlParameterSource paramSource) { |
|
|
|
|
String originalSql = parsedSql.getOriginalSql(); |
|
|
|
|
StringBuilder actualSql = new StringBuilder(); |
|
|
|
|
List<String> paramNames = parsedSql.getParameterNames(); |
|
|
|
|
if (paramNames.isEmpty()) { |
|
|
|
|
return originalSql; |
|
|
|
|
} |
|
|
|
|
StringBuilder actualSql = new StringBuilder(originalSql.length()); |
|
|
|
|
int lastIndex = 0; |
|
|
|
|
for (int i = 0; i < paramNames.size(); i++) { |
|
|
|
|
String paramName = paramNames.get(i); |
|
|
|
|
@ -282,26 +283,26 @@ public abstract class NamedParameterUtils {
@@ -282,26 +283,26 @@ public abstract class NamedParameterUtils {
|
|
|
|
|
Object entryItem = entryIter.next(); |
|
|
|
|
if (entryItem instanceof Object[]) { |
|
|
|
|
Object[] expressionList = (Object[]) entryItem; |
|
|
|
|
actualSql.append("("); |
|
|
|
|
actualSql.append('('); |
|
|
|
|
for (int m = 0; m < expressionList.length; m++) { |
|
|
|
|
if (m > 0) { |
|
|
|
|
actualSql.append(", "); |
|
|
|
|
} |
|
|
|
|
actualSql.append("?"); |
|
|
|
|
actualSql.append('?'); |
|
|
|
|
} |
|
|
|
|
actualSql.append(")"); |
|
|
|
|
actualSql.append(')'); |
|
|
|
|
} |
|
|
|
|
else { |
|
|
|
|
actualSql.append("?"); |
|
|
|
|
actualSql.append('?'); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
else { |
|
|
|
|
actualSql.append("?"); |
|
|
|
|
actualSql.append('?'); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
else { |
|
|
|
|
actualSql.append("?"); |
|
|
|
|
actualSql.append('?'); |
|
|
|
|
} |
|
|
|
|
lastIndex = endIndex; |
|
|
|
|
} |
|
|
|
|
@ -416,9 +417,10 @@ public abstract class NamedParameterUtils {
@@ -416,9 +417,10 @@ public abstract class NamedParameterUtils {
|
|
|
|
|
*/ |
|
|
|
|
public static List<SqlParameter> buildSqlParameterList(ParsedSql parsedSql, SqlParameterSource paramSource) { |
|
|
|
|
List<String> paramNames = parsedSql.getParameterNames(); |
|
|
|
|
List<SqlParameter> params = new LinkedList<SqlParameter>(); |
|
|
|
|
List<SqlParameter> params = new ArrayList<SqlParameter>(paramNames.size()); |
|
|
|
|
for (String paramName : paramNames) { |
|
|
|
|
params.add(new SqlParameter(paramName, paramSource.getSqlType(paramName), paramSource.getTypeName(paramName))); |
|
|
|
|
params.add(new SqlParameter( |
|
|
|
|
paramName, paramSource.getSqlType(paramName), paramSource.getTypeName(paramName))); |
|
|
|
|
} |
|
|
|
|
return params; |
|
|
|
|
} |
|
|
|
|
|