Cayenne User Documentation
Qualifier Expressions

This chapter is dedicated to the use of expressions as qualifiers in SelectQuery. Expressions in general are discussed here.

### Building Qualifier

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)` : Chaining an expression with an already existing qualifier using logical AND.
- `public void orQualifier(Expression e)` : Chaining an expression with an already existing qualifier using logical OR.

### Specifying Join Semantics

Each path expression in a qualifier results in a SQL JOIN in a generated SQL. By default all joins are INNER joins. If LEFT OUTER joins are desirable, users can specify them with a plus sign ("+") after each affected relationship segment in a path expression. E.g. a path like `"paintingArray+.name"` would result in a LEFT OUTER JOIN for an Artist SelectQuery, ensuring that artists without joins are also included in the query result.

.
Copyright ©2001-2010 Apache Software Foundation