Quarkus Queryable documentation

Install the extension, build expressive collection queries, and customize your REST API with filters and lifecycle callbacks.

For the Quarkus extension

This guide covers version 4.0.4 of the Quarkus Queryable extension.

Queryable adds collection filters to Hibernate ORM REST Data with Panache. Quarkus generates the integration at build time; standard CRUD, count, OpenAPI and transactions remain owned by REST Data Panache.

This website guide follows the extension's source documentation.

Installation and first entity

Add version 4.0.4 of the extension to your application:

<dependency>
    <groupId>io.quarkiverse.queryable</groupId>
    <artifactId>quarkus-queryable</artifactId>
    <version>4.0.4</version>
</dependency>

The extension declares its required Quarkus runtime extensions. Applications must still select a JDBC driver and JSON provider, for example quarkus-jdbc-postgresql and quarkus-rest-jackson.

@Entity
@QRs("/api/developers")
@QOrderBy("surname asc")
public class Developer extends PanacheEntityBase {
    @UuidGenerator
    @Id
    @QList
    public String uuid;

    @QLike
    public String name;

    @QLike
    public String surname;

    @QList
    public String team_uuid;

    @QLogicalDelete
    public boolean active = true;
}

REST Data Panache provides POST, GET /{id}, PUT /{id}, DELETE /{id} and GET /count. Queryable replaces the collection GET to support the query parameters below:

GET /api/developers?like.surname=pi
GET /api/developers?obj.team_uuid=<uuid>
GET /api/developers?obj.active=false

Built-in query filters

Queryable annotations are read by Jandex during Quarkus augmentation and produce Criteria API predicates at runtime.

AnnotationDefault parameterBehavior
@Qobj.<field>Equality, inequality, and range comparisons for comparable values.
@QLikelike.<field>Case-insensitive substring, negation, and empty/non-empty checks.
@QRLikerlike.<field>Case-insensitive starts with.
@QLLikellike.<field>Case-insensitive ends with.
@QListobj.<field>Comma-separated IN.
@QLikeListlike.<field>OR of comma-separated substring predicates.
@QNilnil.<field>IS NOT NULL, preserving Queryable legacy semantics.
@QNotNilnotNil.<field>IS NULL, preserving Queryable legacy semantics.
@QLogicalDeleteobj.<field>Defaults to the true/active value.
@QOrderByEntity annotationDefault ordering.

Equality and comparisons

@Q uses obj.<field> for equality and not.<field> for inequality. Range operators are from/gt (>), efrom/gte (>=), to/lt (<), and eto/lte (<=). The name attribute changes the field name for all operators; prefix changes only the equality parameter. Use only one alias for an operator on a field in a request; conflicting aliases return HTTP 400.

GET /products?obj.status=published
GET /products?not.status=archived
GET /products?efrom.price=10&to.price=20

Earlier Queryable versions treated from and to as inclusive. Use efrom and eto to retain that behavior.

String filters

@QLike provides like.<field> (contains), notlike.<field> (does not contain), ie.<field> (empty string), and nie.<field> (non-empty string). The latter two depend on the parameter being present; their values are ignored. SQL null semantics apply, and SQL LIKE wildcards such as % and _ retain their special meaning. Use @QNil or @QNotNil to test for null.

@QRLike matches the beginning of a string with rlike.<field>; @QLLike matches the end with llike.<field>. Both are case-insensitive and support the name and prefix attributes.

Class-level filters and collections

Use @Q on an entity to expose equality filters for supported persistent scalar fields and @ElementCollection fields, including inherited fields. On a mapped superclass, it applies to that superclass's own fields. An explicit field-level @Q overrides its name and prefix; class-level 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 tests equality and membership; not.tags=java tests non-membership. Field-level @Q can also enable membership; supported basic element types include enums. Collections work with OR alternatives but not ranges, and collection counts do not duplicate rows.

Static, transient, embedded and association fields are not exposed automatically; @QLogicalDelete retains its behavior. Class-level @Q can expose identifiers and sensitive fields: use field-level annotations when only specific fields should be searchable. Query filters are not authorization.

java.util.Date ranges

@Q supports equality and ranges on java.util.Date. 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. Use efrom.createdAt=2026-03-10&eto.createdAt=2026-03-10 to include the full day. Equality uses the start of the UTC day.

ISO date-times with offsets are exact instants. 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 plus signs and spaces.

Combining filters with OR

Prefix supported filter parameters with or. to put them in a single OR group. A parameter can be repeated, and different fields and operators can be combined:

GET /customers?or.obj.name=Alice&or.obj.name=Bob
GET /customers?or.obj.name=Alice&or.like.surname=rossi

The operator does not change: or.obj.name means equality, while or.like.surname is a case-insensitive substring. Equality, inequality, ranges, string and directional LIKE filters, lists, and null filters can be combined when their fields expose those filters. Each repeated value contributes an alternative. All ordinary filters remain in AND with the OR group.

Logical-delete filters, fixed EXECUTE_ALWAYS conditions and Hibernate @QFilter conditions stay in AND and cannot be put in the OR group. Unknown, unsupported or invalid or.* parameters return HTTP 400. Collection results and listSize use the same filters; the separate /count endpoint does not.

Query options

QOption.EXECUTE_ALWAYS applies a fixed condition on @Q (typed equality) or @QLike (case-insensitive substring). Request parameters for that annotation, including @Q ranges, are ignored. The condition must be non-empty and valid; specifying a condition without EXECUTE_ALWAYS is rejected.

@Q(condition = "OPEN", options = QOption.EXECUTE_ALWAYS)
public State state;

@QLike(condition = "ACME", options = QOption.EXECUTE_ALWAYS)
public String customerName;

QOption.WITHOUT_PARAMETERS activates an existing Hibernate filter when its query parameter is present, regardless of its value. Omit filterParam; define only one mapping for that filter, whose Hibernate parameters must be absent or have a resolver.

@FilterDef(name = "Contract.current")
@Filter(name = "Contract.current", condition = "archived = false")
@QFilter(name = "Contract.current", queryParam = "only.current",
    options = QOption.WITHOUT_PARAMETERS)

GET /contracts?only.current activates the filter. Other option combinations are unsupported; options on @QList, @QLikeList, @QNil and @QNotNil are ignored. Filters are not authorization.

Custom filters

Place custom filters in service.filters and implement QueryableFilter<T>:

@ApplicationScoped
public class DeveloperFilter implements QueryableFilter<Developer> {
    @Override
    public void contribute(QueryableFilterContext<Developer> context) {
        String team = context.param("team.code");
        if (team != null) {
            context.add(context.criteriaBuilder().equal(
                context.root().get("team").get("code"), team));
        }
    }
}

The context provides a CriteriaBuilder, entity root and query parameters. The entity type is inferred from the generic type, including through generic superclasses. Existing entityType() overrides remain supported.

Custom Criteria filters can contribute alternatives to the OR group:

for (String city : context.orParams("address.city")) {
    context.addOr(context.criteriaBuilder().equal(
        context.root().get("address").get("city"), city));
}

orParams reads all occurrences of or.address.city and marks it as handled. Validate custom values and return a REST error if invalid. Custom parameters are not automatically added to OpenAPI. The context does not expose the enclosing Criteria query, so custom filters cannot create Criteria subqueries directly; use an application-defined Hibernate filter for SQL subqueries.

Hibernate filters and SQL subqueries

Use @QFilter to connect a REST query parameter to an existing Hibernate @FilterDef and @Filter. Hibernate owns the SQL condition and alias handling; Queryable does not generate or modify those annotations.

@Entity
@Table(name = "contracts")
@QRs("/contracts")
@FilterDef(name = "Contract.obj.coordinator_id",
    parameters = @ParamDef(name = "coordinator_id", type = BigDecimal.class))
@Filter(name = "Contract.obj.coordinator_id",
    condition = "exists (select 1 from contract_coordinators coordinator " +
        "where coordinator.contract_uuid = {contract}.uuid " +
        "and coordinator.coordinator_id = :coordinator_id and coordinator.active = 1)",
    deduceAliasInjectionPoints = false,
    aliases = @SqlFragmentAlias(alias = "contract", table = "contracts"))
@QFilter(name = "Contract.obj.coordinator_id",
    queryParam = "obj.coordinator_id",
    filterParam = "coordinator_id")
public class Contract extends PanacheEntityBase {
    // Entity fields and identifier
}

GET /contracts?obj.coordinator_id=123 activates the filter for the collection endpoint. The type comes from Hibernate's definition, so this value is converted to BigDecimal. Invalid values return HTTP 400. Without the parameter, Queryable does not activate the filter.

@QFilter is repeatable: use one annotation per parameter with the same filter name. When any parameter is supplied, all parameters without Hibernate resolvers are required; missing values return HTTP 400. Queryable does not overwrite or disable a filter already enabled on the same Hibernate session; a request trying to activate it fails instead.

The filter is applied independently to the collection query and its listSize count, and disabled on success or failure. It does not apply to the separate REST Data Panache /count endpoint or other CRUD operations. Filter conditions are application-defined SQL: bind values with named parameters and do not treat an optional query filter as authorization.

REST lifecycle and validation

Place lifecycle behavior in service.rs and implement QueryableRsListener<T>.

PhaseCallbacks
Fetch@PreFetch, @PostFetch
List@PreList, @PostList
Create@PrePersist, @PostPersist
Update@PreUpdate, @PostUpdate
Delete@PreDelete, @PostDelete

A callback can take no argument, the entity, its identifier, List<T> for @PostList, or a QueryableEvent<T>. The listener's entity type is inferred from the generic type, including through generic superclasses; existing entityType() overrides remain supported.

Audit fields

@ApplicationScoped
public class DeveloperRsListener implements QueryableRsListener<Developer> {
    @Inject
    SecurityIdentity identity;

    @PrePersist
    void beforeCreate(Developer developer) {
        developer.creationDate = LocalDateTime.now();
        developer.creationUser = identity.getPrincipal().getName();
    }

    @PreUpdate
    void beforeUpdate(Developer developer) {
        Developer persisted = Developer.findById(developer.uuid);
        developer.creationDate = persisted.creationDate;
        developer.creationUser = persisted.creationUser;
        developer.updateDate = LocalDateTime.now();
        developer.updateUser = identity.getPrincipal().getName();
    }
}

Validate before create or update

Use the Queryable listener annotations, not JPA annotations with the same names. Throw a Jakarta REST exception to reject invalid input before the entity is saved:

import jakarta.enterprise.context.ApplicationScoped;
import jakarta.ws.rs.BadRequestException;
import io.quarkiverse.queryable.runtime.PrePersist;
import io.quarkiverse.queryable.runtime.PreUpdate;
import io.quarkiverse.queryable.runtime.QueryableRsListener;

@ApplicationScoped
public class CustomerRsListener implements QueryableRsListener<Customer> {
    @PrePersist
    @PreUpdate
    void validate(Customer customer) {
        if (customer.name == null || customer.name.isBlank()) {
            throw new BadRequestException("name is required");
        }
    }
}

An invalid POST or PUT returns HTTP 400 and the entity write is not performed. The REST framework controls the response body; use a Jakarta REST ExceptionMapper for a custom format. Unmapped runtime exceptions are server errors.

Pre-callbacks can reject or mutate the entity before persistence. Post-callbacks for writes run after commit via JTA synchronizations; their exceptions are logged and cannot roll back an already committed transaction.

Concurrency and virtual threads

Generated endpoints can handle concurrent requests. Queryable keeps query parameters and predicates local to each invocation. Quarkus provides a Hibernate session for the current transaction or, for reads outside a transaction with request-scoped access enabled, for the current request. Hibernate filters enabled by Queryable are scoped to that session and removed after each query, including when the query fails.

With Java 21 or later, enable virtual threads for blocking Quarkus REST endpoints in the application's application.properties and rebuild the application.

quarkus.rest.blocking.signatures.execution.mode=virtual-thread

Application-scoped custom filters and lifecycle listeners must handle concurrent invocations safely. Concurrent updates to the same row follow the application's transaction isolation and locking policy.

Quarkus REST virtual thread guide

Security

Queryable does not introduce a separate authorization system. Use Quarkus HTTP policies for both CRUD endpoints and the collection endpoint:

quarkus.http.auth.permission.developers.paths=/api/developers/*
quarkus.http.auth.permission.developers.policy=authenticated
quarkus.http.auth.permission.developers-list.paths=/api/developers
quarkus.http.auth.permission.developers-list.policy=authenticated

Lifecycle listeners can inject SecurityIdentity for audit fields. Keep creation fields server-owned by restoring them in @PreUpdate. For role-specific access, use Quarkus permission policies, OIDC/JWT or your application's security extension.

Testing real applications

The repository includes an integration application exercising REST, filters, CDI hooks, OpenAPI, security and post-commit behavior:

mvn clean install

A standalone consumer test, outside the Maven reactor, uses the installed extension like an external Quarkus application:

mvn install -DskipTests
mvn -f consumer-tests/pom.xml test

Before a release, validate the pilot matrix:

  • PostgreSQL CRUD service and an entity with a custom QueryableFilter;
  • service using OIDC/JWT and SecurityIdentity;
  • service overriding list/query behavior;
  • existing Queryable 3 project migrated incrementally;
  • JVM build, dev mode and native build.

CI parameterizes the Quarkus version. The source testing guide also describes the intended supported-version matrix and future Ecosystem CI.

Tutorial and source documentation

Explore the Quarkus Queryable tutorial project for an example application, or consult the source documentation for the latest extension reference.

Back to the Quarkus extension overview