Skip Headers

# Parallel Expressions

Previous

Next

Parallel expressions enable you to compare unrelated objects. Parallel expressions require multiple expression builders, but do not require the use of report queries. Each expression must have its own expression builder, and you must use the constructor for expression builder that takes a `class` as an argument. The class does not have to be the same for the parallel expressions, and you can create multiple parallel expressions in a single query.

Only one of the expression builders is considered the primary expression builder for the query. This primary builder makes use of the zero argument expression constructor, and TopLink obtains its class from the query.

Example: A Parallel Expression on Two Independent Employees illustrates how to create an expression that matches all employees with the same last name as another employee of different gender, and accounts for the possibility that returned results could be a spouse.

A Parallel Expression on Two Independent Employees

    ExpressionBuilder emp = new ExpressionBuilder();
    ExpressionBuilder spouse = new ExpressionBuilder(Employee.class);
    Expression exp = emp.get("lastName").equal(spouse.get("lastName"))
      .and(emp.get("gender").notEqual(spouse.get("gender"));