spring-framework / org.springframework.jdbc.core.namedparam / NamedParameterUtils

NamedParameterUtils

abstract class NamedParameterUtils

Helper methods for named parameter parsing.

Only intended for internal use within Spring's JDBC framework.

Author
Thomas Risberg

Author
Juergen Hoeller

Since
2.0

Constructors

<init>

NamedParameterUtils()

Helper methods for named parameter parsing.

Only intended for internal use within Spring's JDBC framework.

Functions

buildSqlParameterList

open static fun buildSqlParameterList(parsedSql: ParsedSql, paramSource: SqlParameterSource): MutableList<SqlParameter>

Convert parameter declarations from an SqlParameterSource to a corresponding List of SqlParameters. This is necessary in order to reuse existing methods on JdbcTemplate. The SqlParameter for a named parameter is placed in the correct position in the resulting list based on the parsed SQL statement info.

buildSqlTypeArray

open static fun buildSqlTypeArray(parsedSql: ParsedSql, paramSource: SqlParameterSource): IntArray

Convert parameter types from an SqlParameterSource into a corresponding int array. This is necessary in order to reuse existing methods on JdbcTemplate. Any named parameter types are placed in the correct position in the Object array based on the parsed SQL statement info.

buildValueArray

open static fun buildValueArray(parsedSql: ParsedSql, paramSource: SqlParameterSource, declaredParams: MutableList<SqlParameter>): Array<Any>

Convert a Map of named parameter values to a corresponding array.

open static fun buildValueArray(sql: String, paramMap: MutableMap<String, *>): Array<Any>

Convert a Map of named parameter values to a corresponding array.

This is a shortcut version of #buildValueArray(ParsedSql, SqlParameterSource, java.util.List).

parseSqlStatement

open static fun parseSqlStatement(sql: String): ParsedSql

Parse the SQL statement and locate any placeholders or named parameters. Named parameters are substituted for a JDBC placeholder.

parseSqlStatementIntoString

open static fun parseSqlStatementIntoString(sql: String): String

Parse the SQL statement and locate any placeholders or named parameters. Named parameters are substituted for a JDBC placeholder.

This is a shortcut version of #parseSqlStatement(String) in combination with #substituteNamedParameters(ParsedSql, SqlParameterSource).

substituteNamedParameters

open static fun substituteNamedParameters(parsedSql: ParsedSql, paramSource: SqlParameterSource): String

Parse the SQL statement and locate any placeholders or named parameters. Named parameters are substituted for a JDBC placeholder, and any select list is expanded to the required number of placeholders. Select lists may contain an array of objects, and in that case the placeholders will be grouped and enclosed with parentheses. This allows for the use of "expression lists" in the SQL statement like: 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.

open static fun substituteNamedParameters(sql: String, paramSource: SqlParameterSource): String

Parse the SQL statement and locate any placeholders or named parameters. Named parameters are substituted for a JDBC placeholder and any select list is expanded to the required number of placeholders.

This is a shortcut version of #substituteNamedParameters(ParsedSql, SqlParameterSource).