Class BeanQuerySession<T>

java.lang.Object
org.apache.juneau.commons.beanquery.BeanQuerySession<T>
Type Parameters:
T - The row (bean) type.
All Implemented Interfaces:
AutoCloseable
Direct Known Subclasses:
InMemoryBeanQuerySession, SqlBeanQuerySession

public abstract class BeanQuerySession<T> extends Object implements AutoCloseable
One unit of query work against a BeanQueryContext: the rows (or connection) to query, plus optional per-request narrowing of the context's settings.

Open a session per request and close it with try-with-resources. A session is not thread-safe. Its public methods are final: each validates the BeanQuery into a ResolvedQuery (throwing BeanQuerySyntaxException for bad input) and then calls the engine's doXxx hook. Engine failures throw BeanQueryExecutionException.

BeanQuerySession.Builder.restrictColumns(String...) only narrows the context's columns. The limit, cap and count-policy overrides replace the context's values for this session (so they can also raise or remove a cap); they are for trusted server-side callers only, never request data.

Example:

// Shortcut: the context's settings as-is. try (InMemoryBeanQuerySession<Person> session = context.getSession(rows)) { Page<Person> page = session.find(query); } // Narrowed for a guest user. try (InMemoryBeanQuerySession<Person> session = context.createSession() .rows(rows) .restrictColumns("name", "city") .defaultLimit(20) .maxLimit(20) .build()) { List<Map<String,Object>> values = session.findValues(query).rows(); }

Since:
10.0.0