Quarkus Queryable
A Quarkus extension for annotation-driven collection filtering with Hibernate ORM REST Data Panache.
Version 4.0.4 · Quarkiverse Hub
Quarkus performs augmentation and bytecode generation at build time. Applications keep their entities and extension points, not generated REST source files.
Standard CRUD, count, OpenAPI and transaction handling are generated by
quarkus-hibernate-orm-rest-data-panache. Queryable contributes
the collection GET endpoint and its richer query language.
Concurrent requests use isolated Hibernate sessions, and generated endpoints support virtual threads when enabled in Quarkus REST. See the concurrency and virtual threads guide.
Install
Add Quarkus Queryable 4.0.4 to your Maven application:
<dependency>
<groupId>io.quarkiverse.queryable</groupId>
<artifactId>quarkus-queryable</artifactId>
<version>4.0.4</version>
</dependency>
Applications also select their JDBC driver and JSON extension:
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-jdbc-postgresql</artifactId>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-rest-jackson</artifactId>
</dependency>
What's new in 4.0.3
- Use
@Qon classes and filter element collections by membership. - Filter
java.util.Dateranges with inclusive UTC day boundaries.
What's new in 4.0.2
- Combine supported filters with
or.*, including repeated values and custom Criteria filters. - Use
EXECUTE_ALWAYSandWITHOUT_PARAMETERSfor fixed conditions and parameterless Hibernate filters.
What's new in 4.0.1
- Connect REST parameters to existing Hibernate filters, including SQL subqueries, with
@QFilter. - Infer the entity type from
QueryableFilter<T>andQueryableRsListener<T>. - Validate creates and updates in lifecycle callbacks using REST exceptions.
Minimal example
@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;
}
Generated API
POST /api/developers
GET /api/developers/{id}
PUT /api/developers/{id}
DELETE /api/developers/{id}
GET /api/developers/count
GET /api/developers?like.surname=pi
GET /api/developers?obj.team_uuid=<uuid>
Extension points
Place custom filters in service.filters:
@ApplicationScoped
public class DeveloperFilter implements QueryableFilter<Developer> {
@Override
public void contribute(QueryableFilterContext<Developer> context) {
// add Criteria API predicates
}
}
Place REST lifecycle callbacks in service.rs:
@PrePersist
void audit(Developer developer) {
developer.creationDate = LocalDateTime.now();
developer.creationUser = identity.getPrincipal().getName();
}
@PostUpdate
void notify(Developer developer) {
// external side effect, executed after commit
}
Callbacks support fetch, list, persist, update and delete. Post-write callbacks are registered as JTA synchronizations and run after a successful commit.
Use @QFilter to activate an existing Hibernate filter from a
REST query parameter. See the Hibernate filter example
for parameter mapping and scope.
Security
Security remains standard Quarkus configuration:
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
Documentation
Build and test
mvn clean install
The reactor contains a complete Quarkus integration application. A standalone consumer test simulates a separate real application:
mvn install -DskipTests
mvn -f consumer-tests/pom.xml test
Quarkus extension design
The implementation follows the main Quarkus extension principles:
- runtime and deployment artifacts are separate;
- application metadata is processed with Jandex during augmentation;
- resources are generated with Gizmo;
- runtime behavior is exposed through CDI extension points;
- native reflection requirements are registered at build time;
- security remains owned by Quarkus configuration;
- tests consume the extension through normal Quarkus augmentation.
The extension is developed in the open in the Quarkiverse repository.
Build with Quarkus Queryable.
Follow the implementation, run the consumer test, and report enterprise migration scenarios.