public abstract class NamedParameterUtils extends Object
Constructor and Description |
---|
NamedParameterUtils() |
Modifier and Type | Method and Description |
---|---|
static List<org.springframework.jdbc.core.SqlParameter> |
buildSqlParameterList(ParsedSql parsedSql,
org.springframework.jdbc.core.namedparam.SqlParameterSource paramSource)
Convert parameter declarations from an SqlParameterSource to a corresponding List of SqlParameters.
|
static int[] |
buildSqlTypeArray(ParsedSql parsedSql,
org.springframework.jdbc.core.namedparam.SqlParameterSource paramSource)
Convert parameter types from an SqlParameterSource into a corresponding int array.
|
static Object[] |
buildValueArray(ParsedSql parsedSql,
org.springframework.jdbc.core.namedparam.SqlParameterSource paramSource,
List<org.springframework.jdbc.core.SqlParameter> declaredParams)
Convert a Map of named parameter values to a corresponding array.
|
static Object[] |
buildValueArray(String sql,
Map<String,?> paramMap)
Convert a Map of named parameter values to a corresponding array.
|
static ParsedSql |
parseSqlStatement(String sql)
Parse the SQL statement and locate any placeholders or named parameters.
|
static String |
parseSqlStatementIntoString(String sql)
Parse the SQL statement and locate any placeholders or named parameters.
|
static String |
substituteNamedParameters(ParsedSql parsedSql,
org.springframework.jdbc.core.namedparam.SqlParameterSource paramSource)
Parse the SQL statement and locate any placeholders or named parameters.
|
static String |
substituteNamedParameters(String sql,
org.springframework.jdbc.core.namedparam.SqlParameterSource paramSource)
Parse the SQL statement and locate any placeholders or named parameters.
|
public static ParsedSql parseSqlStatement(String sql)
sql
- the SQL statementpublic static String substituteNamedParameters(ParsedSql parsedSql, org.springframework.jdbc.core.namedparam.SqlParameterSource paramSource)
select id, name, state from table where (name, age) in (('John', 35), ('Ann', 50))
The parameter values passed in are used to determine the number of placeholders to be used for a select list. Select lists should be limited to 100 or fewer elements. A larger number of elements is not guaranteed to be supported by the database and is strictly vendor-dependent.
parsedSql
- the parsed representation of the SQL statementparamSource
- the source for named parametersparseSqlStatement(java.lang.String)
public static Object[] buildValueArray(ParsedSql parsedSql, org.springframework.jdbc.core.namedparam.SqlParameterSource paramSource, List<org.springframework.jdbc.core.SqlParameter> declaredParams)
parsedSql
- the parsed SQL statementparamSource
- the source for named parametersdeclaredParams
- the List of declared SqlParameter objects
(may be null
). If specified, the parameter metadata will
be built into the value array in the form of SqlParameterValue objects.public static int[] buildSqlTypeArray(ParsedSql parsedSql, org.springframework.jdbc.core.namedparam.SqlParameterSource paramSource)
parsedSql
- the parsed SQL statementparamSource
- the source for named parameterspublic static List<org.springframework.jdbc.core.SqlParameter> buildSqlParameterList(ParsedSql parsedSql, org.springframework.jdbc.core.namedparam.SqlParameterSource paramSource)
parsedSql
- the parsed SQL statementparamSource
- the source for named parameterspublic static String parseSqlStatementIntoString(String sql)
This is a shortcut version of
parseSqlStatement(String)
in combination with
substituteNamedParameters(ParsedSql, SqlParameterSource)
.
sql
- the SQL statementpublic static String substituteNamedParameters(String sql, org.springframework.jdbc.core.namedparam.SqlParameterSource paramSource)
This is a shortcut version of
substituteNamedParameters(ParsedSql, SqlParameterSource)
.
sql
- the SQL statementparamSource
- the source for named parameterspublic static Object[] buildValueArray(String sql, Map<String,?> paramMap)
This is a shortcut version of
buildValueArray(ParsedSql, SqlParameterSource, java.util.List)
.
sql
- the SQL statementparamMap
- the Map of parametersCopyright © 2006–2018 TinyGroup. All rights reserved.