KickJava   Java API By Example, From Geeks To Geeks.

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


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

18 abstract public class StudentBean extends com.caucho.ejb.AbstractEntityBean {
19
20   /**
21    * Returns the name of the student (CMP field).
22    * The name is also the primary key.
23    */

24   abstract public String getName();
25
26   /**
27    * returns a <code>Collection</code> of all <code>Course</code>s the
28    * <code>Student</code> is currently enrolled in.
29    */

30   abstract public Collection getCourseList();
31
32   /**
33    * a little helper to enroll students in a <code>Course</code>
34    */

35   public void addCourse(Course course)
36   {
37     this.getCourseList().add( course );
38   }
39
40   /**
41    * a little helper to drop a <code>Course</code>
42    */

43   public void removeCourse(Course course)
44   {
45     this.getCourseList().remove( course );
46   }
47 }
48
Popular Tags