Tutorials > Program model > Add a finder to an existing entity bean
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
- In the Enterprise Explorer view, navigate to EJB Projects > Order-OrderCaptureData > Deployment Descriptor: Order-OrderCaptureData.
- Double-click Deployment Descriptor: Order-OrderCaptureData to open the deployment descriptor for editing.
- In the Bean tab, select Order from the list of enterprise beans.
- In the lower right pane, scroll down to the Finders list, as in the following screen capture:
- Click Add.
- In the Add Finder Method window:
- In the Name field, enter findOrdersByTimePlaced.
- Click Add to specify a parameter.
- In the Method Parameter window:
- In the Name field, enter memberId.
- From the Type list, select java.lang.Long.
- Click OK.
- From the Return type list, select java.util.Enumeration.
- Click Next.
- In the EJBQL window:
- From the Finder type list, select WhereClauseFinderDescriptor.
- In the Finder statement field, enter T1.MEMBER_ID=? ORDER BY T1.TIMEPLACED.
- Click Finish.
- 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.