KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > example > cmp > many2many > CourseBean


1 package example.cmp.many2many;
2
3 import java.util.*;
4
5 /**
6  * Implementation class for the Course bean.
7  *
8  * <p>This CMP bean uses the following schema:
9  *
10  * <code><pre>
11  * CREATE TABLE many2many_courses (
12  * name VARCHAR(250) NOT NULL,
13  * instructor VARCHAR(250),
14  *
15  * PRIMARY KEY(name)
16  * );
17  * </pre></code>
18  */

19 abstract public class CourseBean extends com.caucho.ejb.AbstractEntityBean {
20
21   /**
22    * Returns the name of the <code>Course</code> (CMP field). This method will
23    * be implemented by Resin-CMP.
24    * It is also the primary key as defined in the deployment descriptor.
25    */

26   abstract public String getName();
27
28   /**
29    * Returns the name of the instructor teaching the <code>Course</course>
30    * (CMP field).
31    * Resin-CMP will implement this method.
32    */

33   abstract public String getInstructor();
34
35   /**
36    * Returns a <code>Collection</code> of all Students that are taking this
37    * course (CMR field).
38    * Resin-CMP will implement this method.
39    */

40   abstract public Collection getStudentList();
41
42   /**
43    * Adds a <code>Student</code> to the <code>Course</course>. This will update
44    * the table many2many_student_course_mapping as defined in the
45    * deployment descriptor.
46    */

47   public void addStudent( Student student )
48   {
49     this.getStudentList().add( student );
50   }
51
52   /**
53    * Removes a <code>Student</code> from the <code>Course</course>. This will
54    * update the table many2many_student_course_mapping as defined in the
55    * deployment descriptor.
56    */

57   public void removeStudent( Student student )
58   {
59     this.getStudentList().remove( student );
60   }
61 }
62
Popular Tags