Class BeanQueryRequest
@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:
How it binds
The type is annotated @Request, so a parameter of this type needs no second 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 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
-
Nested Class Summary
Nested classes/interfaces inherited from class org.apache.juneau.commons.beanquery.BeanQuery
BeanQuery.Builder, BeanQuery.GroupBuilder -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final StringThe response headerRestContext.convertThrowablesets to aBeanQuerySyntaxException'scode()name on every 400 it produces from that exception (with or without problem details). -
Constructor Summary
Constructors -
Method Summary
-
Field Details
-
ERROR_HEADER
The response headerRestContext.convertThrowablesets to aBeanQuerySyntaxException'scode()name on every 400 it produces from that exception (with or without problem details).- See Also:
-
-
Constructor Details
-
BeanQueryRequest
public BeanQueryRequest()
-
-
Method Details
-
getSearch
@Query(schema=@Schema(d="Search expression: comma-separated column=expression clauses, e.g. name=$contains(smith),age=$gte(18). See the BeanQuery search language docs: https://juneau.apache.org/docs/topics/JuneauCommonsBeanQuery")) public String getSearch()Description copied from class:BeanQueryThe one search string. -
getView
Description copied from class:BeanQueryThe raw view (column-selection) directive. -
getSort
@Query(schema=@Schema(d="Comma-separated sort columns; append \":desc\" (or \"-\") for descending.")) public String getSort()Description copied from class:BeanQueryThe raw sort directive. -
getPosition
@Query(schema=@Schema(d="0-based index of the first row.",minimum="0")) public Integer getPosition()Description copied from class:BeanQueryThe 0-based first row of the page.- Overrides:
getPositionin classBeanQuery- Returns:
- The position, or
null for the start of the results.
-
getLimit
@Query(schema=@Schema(d="Maximum rows to return. Defaults and caps are set by the server.")) public Integer getLimit()Description copied from class:BeanQueryThe page size. -
getOpts
Description copied from class:BeanQueryThe one opts string (an open bag ofkey=valueclauses).
-