Tutorials > Program model > Add a finder to an existing entity bean

< Previous | Next >


Create the new finder

In this step we will create a new finder with an SQL query to find a customer's orders and sort the orders by the time the order was placed. The TIMEPLACED column in the ORDERS table holds this information.

To create the new finder:


Procedure

  1. In the Enterprise Explorer view, navigate to EJB Projects > Order-OrderCaptureData > Deployment Descriptor: Order-OrderCaptureData.

  2. Double-click Deployment Descriptor: Order-OrderCaptureData to open the deployment descriptor for editing.

  3. In the Bean tab, select Order from the list of enterprise beans.

  4. In the lower right pane, scroll down to the Finders list, as in the following screen capture:

  5. Click Add.

  6. In the Add Finder Method window:

    1. In the Name field, enter findOrdersByTimePlaced.

    2. Click Add to specify a parameter.

    3. In the Method Parameter window:

    4. In the Name field, enter memberId.

    5. From the Type list, select java.lang.Long.

    6. Click OK.

    7. From the Return type list, select java.util.Enumeration.

    8. Click Next.

  7. In the EJBQL window:

    1. From the Finder type list, select WhereClauseFinderDescriptor.

    2. In the Finder statement field, enter T1.MEMBER_ID=? ORDER BY T1.TIMEPLACED.

    3. Click Finish.

  8. Save the deployment descriptor changes. Rational Application Developer rebuilds the workspace. You will fix errors that might display in the Problems view in the next step.

< Previous | Next >


+

Search Tips   |   Advanced Search