Package org.jumpmind.db.sql
Class NamedParameterUtils
java.lang.Object
org.jumpmind.db.sql.NamedParameterUtils
Helper methods for named parameter parsing. Only intended for internal use within Spring's JDBC framework.
- Since:
- 2.0
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic Object[]
buildValueArray
(ParsedSql parsedSql, Map<String, ?> paramSource) 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
substituteNamedParameters
(ParsedSql parsedSql, Map<String, ?> paramSource) Parse the SQL statement and locate any placeholders or named parameters.
-
Constructor Details
-
NamedParameterUtils
public NamedParameterUtils()
-
-
Method Details
-
parseSqlStatement
Parse the SQL statement and locate any placeholders or named parameters. Named parameters are substituted for a JDBC placeholder.- Parameters:
sql
- the SQL statement- Returns:
- the parsed statement, represented as ParsedSql instance
-
substituteNamedParameters
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 placeholder 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 statementparamSource
- the source for named parameters- Returns:
- the SQL statement with substituted parameters
- See Also:
-
buildValueArray
Convert a Map of named parameter values to a corresponding array.- Parameters:
parsedSql
- the parsed SQL statementparamSource
- the source for named parameters- Returns:
- the array of values
-