example.cmp.one2many
Class HouseBean

example.cmp.one2many.HouseBean

public abstract class HouseBean

Implementation class for the House bean. Each instance of StudentBean maps to a table entry of "one2many_houses", where student is defined.

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.

This CMP bean uses the following schema:

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

     PRIMARY KEY(name)
   );
 


Constructor Summary
HouseBean()
           
 
Method Summary
 void addStudent(Student student)
          Adds a student to the house.
abstract  java.lang.String getName()
          returns the name of the house (CMP field).
abstract  java.util.Collection getStudentList()
          returns a Collection of all Studentss managed by the container (CMR field).
 void removeStudent(Student student)
          Removes a student from the house.
 

Constructor Detail

HouseBean

public HouseBean()
Method Detail

getName

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

getStudentList

public abstract java.util.Collection getStudentList()
returns a Collection of all Studentss managed by the container (CMR field).

This method needs to exist because the field studentList is defined as a CMR field.


addStudent

public void addStudent(Student student)
Adds a student to the house. If the student is already a member of another house, he will be removed from that house automatically.

removeStudent

public void removeStudent(Student student)
Removes a student from the house.