Enterprise Java Development@TOPIC@

Chapter 4. JPAQL Where Clauses

4.1. Equality Test
4.2. Like Test
4.3. Formulas
4.4. Logic Operators
4.5. Equality Tests
4.6. Between
4.7. Testing for Null
4.8. Testing Empty Collection
4.9. Membership Test
4.10. Subqueries
4.11. All
4.12. Any
4.13. Summary

  • Return entities where there is an equality match


  • Escaped special character is passed through to the database














  • 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