objectClass("User") {
search {
sql {
builtIn {
enabled true
where { e ->
e.col("status").ne("deleted")
e.col("legacy").eq(false)
}
}
}
}
}
SQL search and filter support
|
Since 4.11
This functionality is available since version 4.11.
|
The SQL framework provides built-in search for every object class, translating ConnId filters to SQL predicates.
This article is part of the SQL connector development reference and guidance materials. See How to develop connectors using the SQL framework for the section introduction.
Basic search
No configuration is required: for each writable or read-only object class, a built-in search handler is registered.
It selects the mapped columns (__UID__, __NAME__ and all returnedByDefault attributes) with an optional WHERE clause and executes the query in pages of 200 rows.
ConnId AndFilter, OrFilter and NotFilter are translated to SQL AND / OR / negation; each AttributeFilter is resolved through the attribute’s column mapping.
Filter translation
The built-in search handler provides automatic ConnId filter translation to SQL.
Each row of the table lists a ConnId filter operation, the SQL predicate the translator generates for it, and the column type families the operation is supported for — the last column refers to the SQL type family of the filtered column (String columns means string-typed columns such as VARCHAR; Numeric columns means numeric types such as INTEGER or BIGINT).
| ConnId filter | Translated to | Supported by |
|---|---|---|
Equals |
|
All column types |
Contains |
|
String columns |
StartsWith |
|
String columns |
EndsWith |
|
String columns |
GreaterThan |
|
Numeric columns, timestamp/date/time columns |
GreaterThanOrEqual |
|
Numeric columns, timestamp/date/time columns |
LessThan |
|
Numeric columns, timestamp/date/time columns |
LessThanOrEqual |
|
Numeric columns, timestamp/date/time columns |
NotEquals / Present / NotPresent |
not supported by the built-in translator |
— (use Custom search implementation or a |
|
Search by UID
Searching by UID works out of the box — the UID attribute is always resolvable and filterable.
For composite UIDs, pass the joined value (e.g., tenant-1.account-42).
Refining the built-in WHERE clause
Add a fixed predicate on top of the filter-derived WHERE clause (applied to every search, empty filter included). Use it to permanently restrict the rows an object class sees — for example, hiding soft-deleted records (deleted_at IS NULL), limiting an object class to the rows of one tenant, or excluding legacy rows the application no longer reads. The end result: every search against the object class (including searches without any filter) returns only the rows that satisfy both the fixed predicate and the caller’s filter.
Inside the where { e -> } closure (delegated to SqlWherePredicateBuilder):
| Method | Description |
|---|---|
|
Typed column reference, resolved from the discovered table metadata (unknown column → |
|
Adds |
|
Adds |
|
Adds a raw QueryDSL |
The builder exposes only eq and ne. For other comparison operators (gt, lt, ge, le, between, like, …) build a raw QueryDSL predicate — see the QueryDSL BooleanExpression documentation for the full list of predicate methods (the framework uses QueryDSL 5.0.0) — and pass it with e.add(…). For queries with arbitrary predicates, a custom query is usually the cleaner option: its table reference (a.tableRef()) can be used to build typed column paths directly.
|
Always use the explicit eq/ne method calls — Groovy’s == operator maps to Java equals() and will not produce an SQL predicate.
|
All predicates are combined with AND.
To disable the built-in search entirely, use enabled false; see Custom search implementation to replace it with a custom query.