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

substituteNamedParameters

open static fun substituteNamedParameters(parsedSql: ParsedSql, @Nullable 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.

Parameters

parsedSql - the parsed representation of the SQL statement

paramSource - the source for named parameters

Return
the SQL statement with substituted parameters

See Also
#parseSqlStatement

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).

Parameters

sql - the SQL statement

paramSource - the source for named parameters

Return
the SQL statement with substituted parameters