Query filters
Queryable annotations are read by Jandex during Quarkus augmentation. They produce validated Criteria API predicates at runtime.
Built-in annotations
| Annotation | Default parameter | Behavior |
|---|---|---|
|
|
Equality, inequality and range comparisons for comparable values |
|
|
Case-insensitive substring and negation; empty and non-empty strings |
|
|
Case-insensitive starts with |
|
|
Case-insensitive ends with |
|
|
Comma-separated |
|
|
OR of comma-separated substring predicates |
|
|
|
|
|
|
|
|
Defaults to the true/active value |
|
Entity annotation |
Default ordering |
Equality and comparisons
@Q enables these parameters for a scalar field. The name attribute changes
the field name used by all parameters; prefix changes only the equality
parameter.
Parameter |
Alias |
Condition |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
For example, ?efrom.price=10&to.price=20 selects prices greater than or
equal to 10 and strictly less than 20. Comparison parameters require a
comparable field. not.<field> follows SQL null semantics: null values do not
match an inequality.
@Q
public BigDecimal price;
@Q
public String status;
GET /products?obj.status=published
GET /products?not.status=archived
GET /products?gte.price=10<.price=20
Use only one name for an operator on a field in a request, including in its
or. parameters. For example, using both from.price and gt.price
returns HTTP 400. Different operators may be combined normally.
Earlier Queryable versions treated from and to as inclusive.
Replace them with efrom and eto, respectively, to retain that behavior.
|
String filters
@QLike exposes four parameters:
Parameter |
Condition |
|
Contains the value, ignoring case |
|
Does not contain the value, ignoring case |
|
Equals the empty string |
|
Is not the empty string |
ie and nie depend only on the presence of the parameter; their value is
ignored. SQL null semantics apply: null fields do not match notlike, ie or
nie. Empty strings and nulls may be treated identically by some databases.
To test for null, use @QNil or @QNotNil as described above.
SQL LIKE wildcards in like and notlike values, such as % and _,
retain their wildcard meaning.
The name attribute changes the field name for all four parameters; prefix
changes only the positive like parameter. With EXECUTE_ALWAYS, the fixed
substring predicate applies instead and all four request parameters are ignored.
@QLike
public String description;
GET /products?like.description=book
GET /products?notlike.description=book
GET /products?ie.description
GET /products?nie.description
Directional LIKE filters
@QRLike and @QLLike match the beginning and end of a string respectively.
They use rlike.<field> and llike.<field> by default and support the name
and prefix attributes. Both are case-insensitive, like @QLike. Right and
left refer to the side where % is added to the search value.
@QRLike
@QLLike
public String name;
GET /products?rlike.name=book
GET /products?llike.name=press
The first request matches names starting with book; the second matches names
ending with press. SQL LIKE wildcards in the supplied value, such as % and
_, retain their wildcard meaning.
Class-level filters and collections
Apply @Q to an entity class to expose equality filters for its supported
persistent scalar fields and @ElementCollection fields, including inherited
fields. On a mapped superclass, it applies to that superclass’s own fields.
Static, transient, embedded and association fields are not exposed
automatically. @QLogicalDelete retains its existing behavior. An explicit
field-level @Q overrides the generated field name and prefix; class-level
@Q attributes do not configure individual fields.
@Entity
@Q
@QRs("/products")
public class Product extends PanacheEntity {
public String name;
@ElementCollection
public List<String> tags;
}
GET /products?obj.name=Book&obj.tags=java checks equality on name and
membership of java in tags. not.tags=java checks non-membership.
A field-level @Q can also enable membership
without a class-level annotation. Basic element types, including enums, are
converted to the collection element type; ranges are not supported for
collections. OR alternatives work with membership and the collection count
does not duplicate rows.
Class-level @Q exposes all supported persistent fields, potentially including
identifiers and sensitive fields. Use field-level annotations instead when
only selected fields should be searchable. Query filters are not authorization.
java.util.Date ranges
@Q supports java.util.Date for equality and ranges. A date without a
time represents a UTC day: efrom/gte includes its start, eto/lte
includes its end, from/gt starts after its end, and to/lt ends before
its start. For example, efrom.createdAt=2026-03-10&eto.createdAt=2026-03-10
includes the entire UTC day. Equality on a date without a time uses the start
of the UTC day.
An ISO date-time with a UTC offset (such as 2026-03-10T12:30:00+02:00) is
compared as an exact instant; ISO local date-times and the legacy formats
yyyy-MM-dd HH:mm[:ss], dd/MM/yyyy HH:mm[:ss] and
dd/MM/yyyy, HH:mm[:ss] are interpreted in UTC. Invalid dates return HTTP
400. URL-encode + and spaces in query parameter values.
OR filters
Prefix supported query parameters with or. to combine their predicates in
one OR group. Repeat a parameter to include multiple values:
GET /customers?or.obj.name=Alice&or.obj.name=Bob
GET /customers?or.obj.name=Alice&or.like.surname=rossi
The usual operator is unchanged: or.obj.name tests equality, whereas
or.like.surname performs a case-insensitive substring search. @Q equality,
inequality and ranges, @QLike (including notlike, ie and nie),
@QRLike, @QLLike, @QList, @QLikeList,
@QNil and @QNotNil are supported, using their configured parameter names.
For example, ?or.rlike.name=book&or.lt.price=10 selects names beginning
with book or prices below 10. Comma-separated list values retain their usual
semantics. Each occurrence contributes an alternative, including multiple
values for the same parameter.
All non-prefixed filters remain in AND with the OR group. For example,
?obj.country=IT&or.obj.name=Alice&or.obj.name=Bob means
country = 'IT' AND (name = 'Alice' OR name = 'Bob'). The same filters
apply to the result and listSize, before pagination.
No new annotations are needed, but a field must already expose the corresponding
filter. @QLogicalDelete, fixed EXECUTE_ALWAYS conditions and Hibernate
@QFilter conditions remain in AND and cannot be placed in the OR group.
Unsupported or invalid or.* parameters return HTTP 400. These filters are
not authorization controls. The separate /count endpoint is not filtered.
Query options
QOption.EXECUTE_ALWAYS applies a fixed condition on every collection query
when used with @Q or @QLike. Set a non-empty condition: @Q converts it
to the field type and uses equality; @QLike uses a case-insensitive
substring. Query parameters for that annotation, including from and to
ranges for @Q, are ignored.
@Enumerated(EnumType.STRING)
@Q(condition = "BLANK_DELIVERY", options = QOption.EXECUTE_ALWAYS)
public OperationType operationType;
@QLike(condition = "ACME", options = QOption.EXECUTE_ALWAYS)
public String customerName;
An empty or invalid fixed condition is a configuration error. A condition
without EXECUTE_ALWAYS is also rejected. Fixed predicates apply to the
collection and its listSize count, not to the separate /count endpoint
or other CRUD operations; do not use them as authorization.
QOption.WITHOUT_PARAMETERS is supported on @QFilter for activating an
existing Hibernate filter without binding REST values:
@FilterDef(name = "Contract.current")
@Filter(name = "Contract.current", condition = "archived = false")
@QFilter(name = "Contract.current", queryParam = "only.current",
options = QOption.WITHOUT_PARAMETERS)
public class Contract extends PanacheEntityBase {
// Entity fields and identifier
}
GET /contracts?only.current activates the filter; the query parameter’s
value is ignored. Omit filterParam and define only one @QFilter mapping for
that filter. Hibernate filter parameters must either be absent or have a
Hibernate resolver; otherwise the configuration is rejected. Without the REST
parameter, Queryable does not activate the filter.
Other QOption combinations are not supported. The options attributes on
@QList, @QLikeList, @QNil and @QNotNil are currently ignored.
Advanced filters
For custom JPA Criteria predicates, see Custom Criteria filters. For application-defined Hibernate filters and SQL subqueries, see Hibernate filters and SQL subqueries.