When the Filterable API is not enough and you need to have more control, you can make queries directly with the JPA Criteria API. You may also need to customize sorting or joins, or otherwise modify the query in some way. To do so, you need to implement a QueryModifierDelegate that the JPAContainer entity provider calls when making a query. The easiest way to do this is to extend DefaultQueryModifierDelegate, which has empty implementations of all the methods so that you can only override the ones you need.

The entity provider calls specific QueryModifierDelegate methods at different stages while making a query. The stages are:

  1. Start building a query

  2. Add "ORDER BY" expression

  3. Add "WHERE" expression (filter)

  4. Finish building a query

Methods where you can modify the query are called before and after each stage as listed in the following table:


All the methods get two parameters. The CriteriaBuilder is a builder that you can use to build queries. The CriteriaQuery is the query being built.

You can use the getRoots().iterator().next() in CriteriaQuery to get the "root" that is queried, for example, the PERSON table, etc.