Enterprise Java Development@TOPIC@

Chapter 7. Criteria Where Clauses

7.1. Equality Test
7.2. Like Test
7.2.1. Like Test Literal
7.2.2. Like Test Literal Parameter
7.2.3. Like Test Concatenated String
7.2.4. Like Test Single Character Wildcard
7.3. Formulas
7.4. Logic Operators
7.5. Equality Tests
7.6. Between
7.7. Testing for Null
7.8. Testing Empty Collection
7.9. Membership Test
7.10. Subqueries
7.11. All
7.12. Any
7.13. Summary



  • Return entities where there is an equality match



  • JPAQL requires special characters to be escaped


  • Literal values automatically escaped














  • Compare entities and not primary/foreign key values









Can be used to test for unassigned value or relationship







Can be used to test for an empty collection




  • Sub-select returns values from collection under test

  • Outer query tests for no existing (EMPTY)values




  • Sub-select returns values from collection under test

  • Outer query tests for existing (NOT EMPTY)values

Can be used to determine membership in a collection



  • Defines a shorthand for a subquery



Useful when query cannot be expressed through JOINs






  • List all clerks that have all sales above $125.00 or none at all

  • -or- List all clerks with no sale <= $125.00


  • Manny excluded because has 1 sale below $125.00

  • Moe included because has only $150.00 sale

  • Jack included because has no sales that fail criteria



  • List all clerks that have all sales below $125.00 or none at all

  • -or- List all clerks with no sale >= $125.00


  • Manny excluded because has 1 sale above $125.00

  • Moe excluded because has only $150.00 sale

  • Jack included because has no sales that fail criteria



  • List all clerks that have at least one sale above $125.00


  • Manny included because has 1 sale above $125.00

  • Moe included because $150.00 sale qualifies him as well

  • Jack excluded because has no sales that meet criteria



  • List all clerks that have at least one sale below $125.00


  • Manny included because has 1 sale below $125.00

  • Moe excluded because his only $150.00 sale above criteria

  • Jack excluded because has no sales that meet criteria