Adding finder methods to EJB 1.1 entity beans
You can use the Add Finder Descriptor wizard to add finder methods to EJB 1.1 entity beans that are using container-managed persistence.
With the wizard, you can add a new finder method or add one based on an existing finder method that the wizard finds. If the wizard locates no finder methods, create a new one.
To add finder methods to an EJB 1.1 CMP entity bean:
- In the Project Explorer view, right-click the EJB project that includes the entity bean that you want to add a finder method to, and select Open With > Deployment Descriptor Editor from the pop-up menu.
- Select the bean on the Beans page of the editor and scroll to the Finders section.
- Click the Add button. The Add Finder Descriptor wizard opens. If you want to use an existing finder, simply select an existing finder and click Finish. Otherwise, create a new finder.
- If no finders exist, select the New radio button.
- In the Name field, type a name for the new finder. Method names must begin with find.
- Optional: Click Add to add a method parameter to the finder.
- Select a Return type for the finder method, then click Next.
- In the Finder type drop-down menu, select one of the following types:
- EjbqlFinderDescriptor - Select this option if you are using an EJB query language string as the finder statement.
- FullSelectFinderDescriptor - Select this option if you are using an SQL SELECT string as the finder statement. This is also referred to as a SELECT custom finder.
- WhereClauseFinderDescriptor - Select this option if you are using an SQL WHERE clause as the finder statement. This is also referred to as a WHERE custom finder.
- UserFinderDescriptor - Select this option if you are not specifying a string in the finder descriptor. Instead, the finder descriptor will only list the name of the method for the custom finder. If you use this option, make sure that the finder method is implemented correctly.
- If you choose EjbqlFinderDescriptor as the finder type, you can choose a sample EJB QL query in the Select a sample finder field. Your selection populates the Finder statement text area with sample code.
- Complete the query string in the Finder statement text area.
- Click Finish.