Skip to main content

Always Applied Predicate

A predicate added to every query the adapter builds, no matter what the client sends. Use it for rules the user must not be able to lift, such as tenant isolation.

QueryBuilder<Trade, Long, Void> queryBuilder = QueryBuilder.builder(Trade.class, Trade_.tradeId, entityManager)
.colDefs(/* ... */)
.alwaysAppliedPredicate((cb, root) -> cb.equal(root.get(Trade_.tenantId), tenantProvider.currentTenant()))
.build();

It is present in every WHERE clause the adapter builds, so it is always ANDed with the filtering that comes with the request.

Always Applied Predicate Example​

This grid is built with .alwaysAppliedPredicate((cb, root) -> cb.isTrue(root.get(Trade_.isSold))), so it can only ever return sold trades.

  • the Is Sold set filter only offers true, because its values are read through the same predicate
  • Source code for this grid available here
  • Backend source code available here
Loading grid...