intermediateJPQL, Native Queries, Specifications & Criteria API
When would you reach for a Specification instead of a derived query method or JPQL?
When a query's conditions are genuinely dynamic at runtime — for example, a search form where the user may supply any combination of optional filters. A fixed derived method name or JPQL string can't express "this condition, but only if it was supplied"; Specifications compose predicates conditionally at runtime.
Ready to master this question?
Generate a complete walkthrough — background, the full answer in plain language, a working code example explained line by line, a real-world scenario, common mistakes, and how this same question gets asked in different ways.
Sign in to generate a response