Enterprise Java Development@TOPIC@

Chapter 74. Criteria Where Clauses

74.1. Equality Test
74.2. Like Test
74.2.1. Like Test Literal
74.2.2. Like Test Literal Parameter
74.2.3. Like Test Concatenated String
74.2.4. Like Test Single Character Wildcard
74.3. Formulas
74.4. Logic Operators
74.5. Equality Tests
74.6. Between
74.7. Testing for Null
74.8. Testing Empty Collection
74.9. Membership Test
74.10. Subqueries
74.11. All
74.12. Any
74.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