Skip Headers

# Adding Arguments

Previous

Next

Each expression contains elements (arguments) to evaluate. Expressions using the Is Null or Not Null operators require only a single argument.

To add new arguments, use this procedure:

1. Select an existing expression or click Add (or Add Nested) to add a new expression to the named query.

2. For the First Argument, click Edit. The Choose Query Key dialog box appears.

   Choose Query Key

   Description of "Choose Query Key"

3. Select the attribute, specify if the query allows a null value, and click OK.

   Use the Allows Null and Allows None options to define an expression with an outer join.

   Check the Allows Null option to use the `ExpressionBuilder` method `getAllowingNull`.

   Check the Allows None option to use the `ExpressionBuilder` method `anyOfAllowingNone`.

   For more information, see "Using TopLink Expression API For Joins".

4. Use the Operator list to specify how TopLink should evaluate the expression.

5. For the Second Argument, select Literal, Query Key, or Parameter.

   - For Literal arguments, choose the literal type (such as String or Integer) and enter the literal value.

   - For Query Key arguments, click Edit. The Choose Query Key dialog box appears (see step 3 and Figure: Choose Query Key).

   - For Parameter arguments, click Add to add a parameter and then use the list to select it.

Repeat this procedure for each expression or subexpression.

Sample Expression

The following expression will find employees who:

- Have a manager with the last name Jones or have no manager, and

- work on projects with the name Beta or project ID 4, and

- live in Canada and have a salary of more than 25,000, or

  live in the United States and have a salary of more than 37,500

    AND
      1.manager(Allows Null).lastName EQUAL "Jones"
      2.OR
        2.1.projects.name LIKE "BETA"
        2.2.projects.id EQUAL "4"
      3.OR
        3.1.AND
          3.1.1.address.country EQUAL "Canada"
          3.1.2.salary GREATER THAN "25000"
        3.2.AND
          3.1.1.address.country EQUAL "United States"
          3.1.2.salary GREATER THAN "37500"