# How Do I: Add a Finder Method to an Entity Bean?

A finder method returns references to the entity bean(s) that match an EJB QL or WebLogic QL query. The findByPrimaryKey method, which returns a reference to the entity bean, is automatically generated by WebLogic Workshop during building and is defined in both the local and remote home interface. Additional find methods can be added to the EJB's definition. A find method is not implemented in the CMP entity bean class but is defined instead using a @ejbgen:finder tag, which is interpreted by the container.

To Add a Find Method

1. Make sure that the entity bean is displayed in Design View.
2. Right-click the right-hand area of the bean, and choose Add Finder. The Add Finder dialog appears.
3. Enter the correct method name and signature.

   Remember that the method name in the bean's (remote or local) home interface must have the find prefix. To return multiple references, you must use java.util.Collection. To return a unique reference, use the local or remote bean class name (as shown in the Property Editor pane), depending on whether the find method should be defined in the local or remote home interface.

4. Enter EJB QL or WebLogic QL query syntax. Click OK. For more information on this query syntax, see Query Methods and EJB QL.
5. Click the method name to examine the @ejbgen:finder tag in Source View.

Related Topics

How Do I: Add a Home Method to an Entity Bean?

How Do I: Add a Select Method to an Entity Bean?

Query Methods and EJB QL

Developing Enterprise JavaBeans