Finder Methods Sample

A finder method is invoked through a CMP entity bean's (local or remote) home interface, and returns (local or remote) references to the entity beans that match an EJB QL query. This sample shows common finder methods, using EJB QL and WebLogic QL queries.

In the example, an ItemsBean_F EJB models the persistent data in a prefilled database table, representing an inventory of products. Each items has a product name, a quantity that is in stock, and a price. In addition, this EJB has an entity relationship with the ManufacturerBean_F EJB, which holds information about the various manufacturers known for these products. Each product has one manufacturer, and a manufacturer has multiple products. Various finder methods are used to obtain information about the records in the database tables.

Concepts Demonstrated by this Sample

Location of Sample Files

The code of the CMP entity beans is located in the finderMethods folder of the EJBs project in the SamplesApp sample application. In the file system the location is:

BEA_HOME\weblogic81\samples\workshop\SamplesApp\EJBs\finderMethods

The web services that you run as a client application to test the EJBs, and the EJB controls that you use to locate and reference the EJBs, are located in the finderMethods folder of the EJBs_ClientApps project in the SamplesApp sample application. In the file system the location is:

BEA_HOME\weblogic81\samples\workshop\SamplesApp\EJBs_ClientApps\finderMethods

To Run the Sample

  1. Start WebLogic Server in the appropriate domain.
  1. Launch the ItemsBeanControlTest web service either by opening it in WebLogic Workshop and selecting the Start operation or by entering http://localhost:7001/EJBs_ClientApps/finderMethods/ItemsBeanControlTest.jws in the address bar of your browser. If WebLogic Server is running in the appropriate domain on this machine, you may click here to run the sample.
  2. Navigate to the Test Form tab of Test View, if necessary.
  3. Invoke the startTestDrive method to create a new conversational instance.
  4. Click continue this conversation.
  5. Browse through the finder methods and select one you would like to run. Follow the instructions given for the method and observe the outcome.
  6. Repeat the last two steps for the other finder methods you would like to run.
  7. Return to WebLogic Workshop and press the Stop button to close the Test Browser.

  8. Launch the ManufacturerBeanControlTest web service either by opening it in WebLogic Workshop and selecting the Start operation or by entering http://localhost:7001/EJBs_ClientApps/finderMethods/ManufacturerBeanControlTest.jws in the address bar of your browser. If WebLogic Server is running in the appropriate domain on this machine, you may click here to run the sample.
  9. Repeat steps 3 through 8 to test the finder methods available through this web service.

Related Topics

Home Methods Sample

@ejbgen:select Annotation