Adding finder methods to CMP 1.x beans

You can use the Add Finder Descriptor wizard to add finder methods to CMP 1.x 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, you must create a new one.

To add finder methods to a CMP 1.x bean :

  1. Switch to the J2EE perspective.
  2. In the Project Explorer view, select the desired EJB JAR file.
  3. Right-click on the Deployment Descriptor Editor and select Open With from the pop-up menu.
  4. Select the bean on the Bean page of the editor and scroll to the Finders section.
  5. Click Add. The Add Finder Descriptor wizard opens. If you want to use an existing finder, simply select an existing finder and click Finish. Otherwise, you must create a new finder.
  6. If no finders exist, select New.
  7. In the Name field, type a name for the new finder. Method names must begin with find.
  8. Optional: Click Add to add a method parameter to the finder.
  9. Select a Return type for the finder method, then click Next.
  10. In the Finder type list, 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, you must make sure that the finder method is implemented correctly.
  11. 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 field with sample code.
  12. Complete the query string in the Finder statement field.
  13. Click Finish.

Feedback