This chapter is dedicated to the use of expressions as qualifiers. A detailed discussion on expressions in general is provided at Expressions.

The previous chapter showed how to build a query to fetch all data from a single table. In most situations though only a subset of data matching a certain criteria is needed. Cayenne provides an expressions package to control the filtering behavior of the queries. Expressions applied to queries are called "qualifiers".

SelectQuery provides a few ways to initialize and modify the qualifier:

  • public SelectQuery(Class objectClass, Expression e)
    Passing expression as a second argument in constructor.
  • public void setQualifier(Expression qualifier)
    Explicitly setting the qualifier expression.
  • public void andQualifier(Expression e)
    Adding an expression to an already existing qualifier using logical AND.
  • public void orQualifier(Expression e)
    Adding an expression to an already existing qualifier using logical OR.