public record SqlRestriction extends java.lang.Record
Criterion that restricts the results with a native SQL condition, created by sqlRestriction in a
criteria query. In the SQL, {alias} stands for the table alias of the queried entity, and each
? outside a string literal, a quoted identifier and a comment for one of the values, which are bound
as parameters. The SQL is read in the SqlSyntax of the database: of checks the placeholders
against the values when the restriction is created, and the query that renders it checks them again.
The canonical constructor checks that the SQL and the values are not null and copies the values, but does
not count the placeholders, because the count depends on the syntax of the database, which a restriction built
without a connection does not know. The count is checked where the SQL is rendered, on the connection the query
runs on, and earlier by of(String, List, SqlSyntax) where the connection is known.
sql - the SQL conditionvalues - the values of the ? placeholders, in order| Constructor and description |
|---|
SqlRestriction() |
| Type Params | Return Type | Name and description |
|---|---|---|
|
public static SqlRestriction |
of(java.lang.String sql, java.util.List<?> values, SqlSyntax syntax)Creates the restriction, checking that the SQL, read in the syntax of the database, has one ?
|
| Methods inherited from class | Name |
|---|---|
class java.lang.Record |
java.lang.Record#equals(java.lang.Object), java.lang.Record#getClass(), java.lang.Record#hashCode(), java.lang.Record#notify(), java.lang.Record#notifyAll(), java.lang.Record#toString(), java.lang.Record#wait(), java.lang.Record#wait(long), java.lang.Record#wait(long, int) |
Creates the restriction, checking that the SQL, read in the syntax of the database, has one ?
placeholder per value. A ? in a string literal, a quoted identifier, a line comment or a block comment
is not a placeholder; nor is one in a bracket identifier where the syntax has them.
null, a value is null, or the number of
placeholders differs from the number of valuessql - the SQL conditionvalues - the values of the ? placeholders, in order, none of them nullsyntax - the syntax of the database's native SQL