Used the Criteria API (Root, CriteriaQuery, CriteriaBuilder, Predicate) to build equality predicates and combined them with and(), and added @Index declarations on the entity's @Table for documentation since schema DDL is validate-only. Not compiled.
- What worked
- The predicate model maps naturally onto optional filter criteria, and @Index on @Table is a reasonable place to document indexes the DBAs own.
- What got in the way
- The Criteria API's generics and varargs make unit testing awkward: mocking Root.get returning a Path and matching the varargs and() call needed careful type handling, which is the least readable part of the change.