Interface SearchSqlRenderer
- Functional Interface:
- This is a functional interface and can therefore be used as the assignment target for a lambda expression or method reference.
WHERE clause.
The renderer receives the target SqlDialect, the already-quoted column reference, the column's
value type (so it can bind values as the right JDBC type), and the operator's arguments (typed
values when the operator asks for them, otherwise the literal strings; see SearchOperator.Builder#typedArgs(boolean)),
and returns a SqlFragment (a boolean SQL expression plus its ordered bind values). It is the
SQL-side analog of SearchPredicate (the in-memory evaluator): built-in operators do not use it — their
SQL comes from SqlDialect.builtinRenderer(String).
A renderer is attached to a SearchOperator as a typed extension keyed by this interface, with
extension(SearchSqlRenderer.class, renderer); the context retrieves it with SearchOperator.extension(Class),
so commons never depends on SQL dialect types. A
renderer that does not support the supplied dialect returns SqlFragment binds, never concatenated into the
SQL text.
For the built-in value operators, and for a custom operator built with typedArgs(true), each argument arrives
already parsed by SearchType.parse(String) during query resolution: a BigDecimal for a
NUMERIC column, a Boolean for BOOLEAN, and an OffsetDateTime,
LocalDateTime or LocalDate for TIMESTAMP. Text-like types
(TEXT, ID, ENUM, VERSION) are always String. A malformed value never reaches a
renderer; it fails resolution with code BAD_VALUE.
Example:
- Since:
- 10.0.0
-
Method Summary
Modifier and TypeMethodDescriptionrender(SqlDialect dialect, String columnSql, SearchType type, List<Object> args) Renders this custom operator into a SQL predicate fragment.
-
Method Details
-
render
Renders this custom operator into a SQL predicate fragment.- Parameters:
dialect- The target SQL dialect. Nevernull .columnSql- The dialect-quoted column reference the predicate applies to (for example"\"age\""). Nevernull .type- The column's value type, so the renderer can bind values as the right JDBC type. Nevernull .args- The operator's arguments (nevernull ; may be empty):typed values(BigDecimal,Boolean,OffsetDateTime,LocalDateTime,LocalDate, orStringfor text-like types) for a built-in value operator or a custom operator withtypedArgs(true); plainStringliterals otherwise.- Returns:
- The predicate fragment, or
null if this renderer does not supportdialect.
-