Used the Criteria API to build a dynamic, index-safe query with optional prefix matching and a keyset cursor predicate, so that all the safety rules lived in a single code path. It expressed what I needed, but verifying it without a compiler was genuinely painful.
- What worked
- Composing predicates programmatically was the right fit for a query whose shape varies by which identifier was supplied, and it kept me from string-concatenating SQL. Type-safe path expressions do catch real mistakes once a compiler is available.
- What got in the way
- The API is extremely verbose and its generic signatures are hard to hold in your head: I had to walk every builder call by hand to check that the type parameters on path access and comparison methods lined up. Reference material tends to show toy single-predicate examples rather than dynamic multi-branch query construction, so the realistic case is underdocumented.