Class BeanQueryRequest

java.lang.Object
org.apache.juneau.commons.beanquery.BeanQuery
org.apache.juneau.http.BeanQueryRequest

@Request public class BeanQueryRequest extends BeanQuery
The HTTP-binding @Request bean for BeanQuery-style list queries.

This is a concrete BeanQuery subclass — not an interface — so it is the carrier the query engine consumes. Binding a list REST operation to a single BeanQueryRequest argument populates the inherited search / view / sort / position / limit / opts fields straight from the request, with no adapter step.

Example:

private static final InMemoryBeanQueryContext<Row> ROWS = InMemoryBeanQueryContext .create(Row.class) .build(); @RestGet public List<Row> getList(BeanQueryRequest q) { try (InMemoryBeanQuerySession<Row> s = ROWS.getSession(rows)) { return s.find(q).rows(); } }

How it binds

The type is annotated @Request, so a parameter of this type needs no second @Request on the parameter. Because it is a concrete class, the framework instantiates it with its public no-arg constructor and calls the JavaBeans setter matching each annotated getter (so getOpts() is populated via setOpts). Each getter is a single-valued @Query: exactly one search parameter and one opts parameter bind — the $-language and the key=value opts bag live inside those single strings and are decoded by the session, not on the wire.

Wire names

Every @Query name equals its Java property name: search, view, sort, position, limit, opts. A resource that wants a different name (or extra parameters) subclasses this bean and redeclares the getter with its own @Query name.

Swagger

Each getter carries a @Schema description, so an operation taking this bean documents all six parameters automatically; position also declares minimum=0, so a negative value fails part validation (HTTP 400) before the query runs. limit has no minimum: the context clamps it instead.

Saved-view clash

getView() is a column projection (field names), not a saved-view id. Saved-view CRUD endpoints must not take BeanQueryRequest; they keep their own @Query("view") id parameter, or the wrong meaning of view would bind.

Errors

A malformed search (or any other clause the session rejects) throws BeanQuerySyntaxException, which RestContext.convertThrowable maps to an HTTP 400 carrying an "X-BeanQuery-Error" header and, with problem details on, a "code" member:

GET /people?search=pasword=x&sort=name,age:desc&view=name,age&position=20&limit=10 HTTP/1.1 400 Bad Request X-BeanQuery-Error: UNKNOWN_COLUMN { "status": 400, "title": "Bad Request", "detail": "Unknown column 'pasword' in search.", "code": "UNKNOWN_COLUMN" }

See Also:
Since:
10.0.0