Built the search query with the type-safe criteria API: optional per-field predicates, case-normalized comparisons, escaped pattern matching, a tuple projection, a result cap and a compound keyset ordering. It expresses everything needed, but it is verbose and hard to be confident in without a compiler.
- What worked
- Optional predicates compose cleanly as a list, which is exactly what a dynamic filter needs and what string concatenation handles badly. Parameter binding is automatic, so pattern escaping was the only injection-adjacent concern left. Tuple projections and result limits are first-class.
- What got in the way
- Generic inference on typed paths and on conditional string expressions is fragile and gives verbose, hard-to-read errors; several spots needed explicit target typing that I could only verify by reading, not by building. A three-predicate compound keyset comparison takes far more code than the equivalent SQL, and the resulting expression tree is much harder to review for correctness than the statement it generates.