example.cmp.select
Class HouseBean

example.cmp.select.HouseBean

public abstract class HouseBean

Implementation class for the House bean.

 CREATE TABLE select_house (
   name VARCHAR(250) NOT NULL,

   PRIMARY KEY(name)
 );
 

HouseBean is abstract since it's taking advantage of container-managed persistence. Resin-CMP will create the implementation of the abstract methods.

HouseBean also takes advantage of the AbstractEntityBean implementation. AbstractEntityBean is just a stub EntityBean implementation with default methods to make life a little more sane for simple beans.


Constructor Summary
HouseBean()
           
 
Method Summary
abstract  java.util.Collection ejbSelectAllBoys(House house)
          Returns a Collection of Strings of all Student's names who are boys.
 java.util.List getAllBoyNamesSorted()
          The business method to find the boys in this house.
abstract  java.lang.String getName()
          Returns the name of the house.
abstract  java.util.Collection getStudentList()
          returns a Collection of all Students living in this House (CMR field).
 

Constructor Detail

HouseBean

public HouseBean()
Method Detail

getName

public abstract java.lang.String getName()
Returns the name of the house. The name is the primary key as defined in the deployment descriptor.

getStudentList

public abstract java.util.Collection getStudentList()
returns a Collection of all Students living in this House (CMR field).

ejbSelectAllBoys

public abstract java.util.Collection ejbSelectAllBoys(House house)
                                               throws javax.ejb.FinderException
Returns a Collection of Strings of all Student's names who are boys. Since the ejbSelect method can't be exposed in the local interface, we need to add a business method to return the names.

As the example shows, ejbSelect methods can return collections and values of any type storable in the database. In contrast, find methods must always return the local interface of entity beans.

The ORDER BY clause is a Resin-CMP extension to the EJB-QL spec. A later version of the EJB spec will almost certainly contain similar functionality.

 SELECT student.name
 FROM select_house house, IN(house.studentList) student
 WHERE student.gender='Boy' AND house=?1
 ORDER BY student.name
 

getAllBoyNamesSorted

public java.util.List getAllBoyNamesSorted()
The business method to find the boys in this house. Because ejbSelect methods can only be called by the bean implementation, we need a business method to return the names.