# ItemsBean_F.ejb Sample

This topic inludes the source code for the ItemsBean_F.ejb Sample.

## Sample Location

This sample is located in the following directory in your WebLogic Workshop installation:

BEA_HOME/weblogic81/samples/workshop/SamplesApp/EJBs/finderMethods/

## Sample Source Code

`001 package finderMethods; 002 003 import java.util.Collection; 004 import javax.ejb.CreateException; 005 import weblogic.ejb.GenericEntityBean; 006 007 /** 008 * @ejbgen:entity default-transaction="Supports" concurrency-strategy="ReadOnly" 009 * ejb-name="ItemsBean_F" 010 * data-source-name = "cgSampleDataSource" 011 * table-name="EJB_ITEMS" 012 * prim-key-class = "java.lang.Integer" 013 * 014 * @ejbgen:jndi-name 015 * local="ejb.ItemsBean_FHome" 016 * 017 * @ejbgen:file-generation local-class = "true" local-class-name="Items_F" local-home = "true" local-home-name="Items_FHome" remote-class="false" remote-class-name = "ItemsRemote" remote-home="false" remote-home-name = "ItemsRemoteHome" value-class = "true" value-class-name = "ItemVO" pk-class = "true" 018 * @ejbgen:relation role-name="ItemsBean_Fs-have-ManufacturerBean_F" fk-column="MANUFACTURER" cmr-field="manufacturer" target-ejb="ManufacturerBean_F" multiplicity="Many" name="ItemsBean_F-ManufacturerBean_F" 019 * @ejbgen:finder ejb-ql="SELECT OBJECT(o) from ItemsBean_F as o WHERE o.itemname = ?1" generate-on="Local" signature="Collection findByItemName(java.lang.String itemname)" 020 * @ejbgen:finder ejb-ql="SELECT OBJECT(i) from ManufacturerBean_F as o, IN(o.items) AS i WHERE o.usManufacturer= 1" generate-on="Local" signature="Collection findByUSManufacturer()" 021 * @ejbgen:finder weblogic-ejb-ql="SELECT OBJECT(i) from ManufacturerBean_F as o, IN(o.items) AS i WHERE o.usManufacturer= 1 ORDERBY i.itemname" ejb-ql="SELECT OBJECT(i) from ManufacturerBean_F as o, IN(o.items)" generate-on="Local" signature="Collection findByUSManufacturerOrdered()" 022 * @ejbgen:finder generate-on="Local" ejb-ql="SELECT OBJECT(o) from ItemsBean_F as o" signature="Collection findAll()" 023 * @ejbgen:finder ejb-ql="SELECT OBJECT(o) from ItemsBean_F as o WHERE o.price > ?1 AND o.quantityavailable > ?2" generate-on="Local" signature="Collection findByPriceAndQuantity(double price, int stock)" 024 * @ejbgen:finder weblogic-ejb-ql="SELECT OBJECT(o) from ItemsBean_F as o WHERE o.price > (SELECT AVG(s.price) FROM ItemsBean_F AS s)" ejb-ql="SELECT OBJECT(o) from ItemsBean_F as o" generate-on="Local" signature="Collection findAboveAverage()" 025 * @ejbgen:finder weblogic-ejb-ql="SELECT OBJECT(mainItem) from ItemsBean_F as mainItem WHERE 5 > (SELECT COUNT(subItem.itemname) FROM ItemsBean_F AS subItem WHERE subItem.price < mainItem.price)" ejb-ql="SELECT OBJECT(o) from ItemsBean_F as o" generate-on="Local" signature="Collection findFiveCheapestItems()" 026 * @ejbgen:finder weblogic-ejb-ql="SELECT OBJECT(mainItem) from ItemsBean_F as mainItem WHERE NOT EXISTS (SELECT OBJECT(subItem) FROM ItemsBean_F as subItem WHERE subItem.price > mainItem.price)" ejb-ql="SELECT OBJECT(o) from ItemsBean_F as o" generate-on="Local" signature="Collection findMostExpensiveItems()" 027 */ 028 029 public abstract class ItemsBean_F extends GenericEntityBean 030 { 031 032 033 /** 034 * @ejbgen:cmp-field column = "ITEMNUMBER" 035 * primkey-field="true" 036 * @ejbgen:local-method 037 */ 038 public abstract Integer getItemnumber(); 039 /** 040 * @ejbgen:local-method 041 */ 042 public abstract void setItemnumber(Integer val); 043 044 /** 045 * @ejbgen:cmp-field column = "ITEMNAME" 046 * @ejbgen:local-method 047 */ 048 public abstract String getItemname(); 049 /** 050 * @ejbgen:local-method 051 */ 052 public abstract void setItemname(String val); 053 054 /** 055 * @ejbgen:cmp-field column = "PRICE" 056 * @ejbgen:local-method 057 */ 058 public abstract double getPrice(); 059 /** 060 * @ejbgen:local-method 061 */ 062 public abstract void setPrice(double val); 063 064 /** 065 * @ejbgen:cmp-field column = "QUANTITYAVAILABLE" 066 * @ejbgen:local-method 067 */ 068 public abstract int getQuantityavailable(); 069 /** 070 * @ejbgen:local-method 071 */ 072 public abstract void setQuantityavailable(int val); 073 074 075 public java.lang.Integer ejbCreate(java.lang.Integer Itemnumber) 076 { 077 setItemnumber(Itemnumber); 078 079 return null; // FIXME return PK value 080 } 081 082 public void ejbPostCreate(java.lang.Integer Itemnumber) 083 { 084 } 085 086 /** 087 * @ejbgen:cmr-field 088 * @ejbgen:local-method 089 */ 090 public abstract ManufacturerBean_FLocal getManufacturer(); 091 092 /** 093 * @ejbgen:local-method 094 */ 095 public abstract void setManufacturer(ManufacturerBean_FLocal arg); 096 097 /** 098 * @ejbgen:local-method 099 */ 100 public String toString() 101 { 102 return "["+getItemnumber().toString()+","+getItemname()+","+getPrice()+","+getQuantityavailable()+"]"; 103 } 104 }`