Building Expressions

Use the Expression Builder to create TopLink Expression queries.

To Build an Expression:

  1. From the Named Queries Format tab (see Figure 4-5), click Edit (or double-click a query string). The Expression Builder dialog box appears.

    Figure 4-8 Expression Builder

    This figure shows the main parts of the Expression Builder dialog box.

    Figure 4-8 calls out the following user-interface components:
    1. Expression tree
    2. Arguments
  2. Click Add or Add Nested to create a new expression. TopLink assigns a sequence number to each node and nested node.
    Click Remove to remove an existing expression.
  3. Select the node and use the Logical Operator drop-down list to specify the operator for the node (AND, OR, Not AND, or Not OR).
  4. Choose the expression and complete the "Adding Arguments" procedure.
  5. Click OK.

Adding Arguments

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

Use this procedure to add new arguments.

  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.

    Figure 4-9 Choose Query Key

    This figure shows Choose Query Key dialog box.

  3. Select the attribute, specify if the query allows a null value, and click OK.
  4. Use the Operator drop-down list to specify how TopLink should evaluate the expression.
  5. For the Second Argument, select Literal, Query Key, or Parameter, and click Edit.

Repeat this procedure for each expression or sub-expression.

Example 4-2 Sample Expression

This expression:

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"

will find employees who:

 

Copyright © 1997, 2004, Oracle. All rights reserved.