This class expands SQL from named parameters to native
style placeholders at execution time. It also allows for expanding
a List of values to the appropriate number of placeholders.
References to the same parameter name are substituted with the
same bind marker placeholder if a BindMarkersFactory uses
identifiable placeholders.
Note
An instance of this class is thread-safe once configured.
| Modifier and Type | Field and Description |
|---|---|
| public static final int | DEFAULT_CACHE_LIMIT
Default maximum number of entries for the SQL cache: 256. |
| private final ConcurrentLruCache | parsedSqlCache
Cache of original SQL String to ParsedSql representation. |
| Access | Constructor and Description |
|---|---|
| pack-priv |
| Modifier and Type | Method and Description |
|---|---|
| public PreparedOperation | Returns: the expanded sql that accepts bind parameters and allows for execution without further translation wrapped asPreparedOperation.the original SQL statement sql, BindMarkersFactory the bind marker factory bindMarkersFactory, BindParameterSource the source for named parameters paramSource)Parse the SQL statement and locate any placeholders or named parameters. |
| public List | Returns: the parameter namesParse the SQL statement and locate any placeholders or named parameters. |
| private ParsedSql | Returns: a representation of the parsed SQL statementthe original SQL statement sql)Obtain a parsed representation of the given SQL statement. |
| DEFAULT_CACHE_LIMIT | back to summary |
|---|---|
| public static final int DEFAULT_CACHE_LIMIT Default maximum number of entries for the SQL cache: 256. | |
| parsedSqlCache | back to summary |
|---|---|
| private final ConcurrentLruCache<String, ParsedSql> parsedSqlCache Cache of original SQL String to ParsedSql representation. | |
| NamedParameterExpander | back to summary |
|---|---|
| pack-priv NamedParameterExpander() | |
| expand | back to summary |
|---|---|
| public PreparedOperation Parse the SQL statement and locate any placeholders or named parameters. Named parameters are substituted for a native 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.
| |
| getParameterNames | back to summary |
|---|---|
| public List Parse the SQL statement and locate any placeholders or named parameters. Named parameters are returned as result of this method invocation. | |
| getParsedSql | back to summary |
|---|---|
| private ParsedSql getParsedSql(String sql) Obtain a parsed representation of the given SQL statement. The default implementation uses an LRU cache with an upper limit of 256 entries. | |