How it works · Chenile Query

A query is configuration, and the read side stays separate

Commands write through JPA. Queries read through MyBatis, from views shaped for reading. A named query is a JSON definition and a select: post JSON to /q/{name} and get back rows, paging and the actions allowed on each row, already filtered by who you are.

A named query: from JSON request to rows with allowed actions A UI or an agent posts a search to /q/accounts as JSON. The pipeline checks the query's own authorities, and the user filter adds the ids whose data the caller may see. The service looks up the tenant's definition of the query, turns the filters into like, IN and between values from its column metadata, adds sorting and paging, picks the tenant's database, and runs a MyBatis select on a view joined with the security table. Rows come back as maps, each with the workflow actions allowed in its state. Variants show a caller without the authority and a tenant without its own definition. UI or agentPOST /q/accounts chenile-highwaytenant · query acls user filterauthIds: me + reportees NamedQueryServicesearch(name, request) query definitionsaccounts · acme override filters from metadatalike · in · between · sort · page MyBatis mapperAccount.search routing datasourceacme → acme DB acme database · domain and security tables together account_summary_vaccount ⨝ customer account_accesswho may see which account · customer · …the tables commands write (JPA) SearchResponserows · actions · columns · paging workflow (Finito)allowed actions per row rows as JSON maps (or your DTOs), each with the actions allowed in its state needs: QUERY_READ
scenario
tenant
view
Step 1

Exchange

Payload

Read from views, not entities

The select reads a view where joins and calculations are done up front, so a filter on a customer's last name or a computed balance costs nothing extra. The entity tables stay the commands' business.

Security in the query

Each query carries its own acls, per tenant. Relationship filters, such as the caller and their reportees, are added on the server and joined against security tables kept in the same database.

JSON in, JSON out

A grid or an AI agent sends filters as JSON and gets rows as maps; no Java DTO is required on either side. Java callers can still map rows to DTOs, and each query is also an MCP tool.