A select method is a private method that can only be used internally by a CMP entity bean class, that is, it is not defined in the bean's interfaces. The method can return (local or remote) references to the entity beans or the values of an individual CMP field that match an EJB QL or WebLogic QL query. This sample shows mostly common select methods that return the values of an individual CMP fields. Because select methods can only be used internally, various business methods are defined that use these select methods.
Note. For more examples of (WebLogic) EJB QL queries that returns references entity beans, see the Finder Methods Sample. For examples of a select method that is used by various home methods, see the Home Methods Sample.
In the example, an ItemsBean_S 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_S EJB, which holds information about the various manufacturers known for these products. Each product has one manufacturer, and a manufacturer has multiple products. Various select methods are used to obtain information about the items in the database. For each select method a home method is created with a matching name that simply returns the results of the select method as a String. For more information on common uses of home methods, see the Home Methods Sample mentioned above.
Examining an EJB at runtime using a conversational web service via an EJB control.
The code of the CMP entity bean is located in the selectMethods folder of the EJBs project in the SamplesApp sample application. In the file system the location is:
BEA_HOME\weblogic81\samples\workshop\SamplesApp\EJBs\selectMethods\ItemsBean_S.ejb
The web service that you run as a client application to test the EJB, and the EJB control that you use to locate and reference the EJB, are located in the selectMethods folder of the EJBs_ClientApps project in the SamplesApp sample application. In the file system the location of the web service is:
BEA_HOME\weblogic81\samples\workshop\SamplesApp\EJBs_ClientApps\selectMethods\ItemsBeanControlTest.jws
To Run the Sample
BEA_HOME/weblogic81/samples/workshop/startWebLogic.sh