KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > example > cmp > map > GradeBean


1 package example.cmp.map;
2
3 import javax.ejb.*;
4
5 /**
6  * Implementation class for the Grade bean.
7  *
8  * <p>The Grade has a compound key with two identifying fields: the
9  * Student and the Course.
10  *
11  * <p>This CMP bean uses the following schema:
12  *
13  * <code><pre>
14  * CREATE TABLE map_grades (
15  * student VARCHAR(250) NOT NULL REFERENCES map_students(name),
16  * course VARCHAR(250) NOT NULL REFERENCES map_courses(name),
17  *
18  * grade VARCHAR(3),
19  *
20  * PRIMARY KEY(student, course)
21  * );
22  * </pre></code>
23  */

24 abstract public class GradeBean extends com.caucho.ejb.AbstractEntityBean {
25   /**
26    * Returns the Grade's student. This is part of the primary key.
27    */

28   abstract public Student getStudent();
29   /**
30    * Sets the Grade's student. Since this is part of the primary
31    * key, it it only set in ejbCreate.
32    */

33   abstract public void setStudent(Student student);
34   /**
35    * Returns the Grade's course. This is part of the primary key.
36    */

37   abstract public Course getCourse();
38   /**
39    * Sets the Grade's course. Since this is part of the primary
40    * key, it it only set in ejbCreate.
41    */

42   abstract public void setCourse(Course course);
43   /**
44    * Returns the grade.
45    */

46   abstract public String getGrade();
47   /**
48    * Sets the grade.
49    */

50   abstract public void setGrade(String grade);
51
52   /**
53    * Create a new grade object.
54    */

55   public GradeKey ejbCreate(Student student, Course course, String grade)
56     throws CreateException
57   {
58     setStudent(student);
59     setCourse(course);
60     setGrade(grade);
61
62     return null;
63   }
64   
65   /**
66    * Create a new grade object.
67    */

68   public void ejbPostCreate(Student student, Course course, String grade)
69     throws CreateException
70   {
71     setStudent(student);
72     setCourse(course);
73     setGrade(grade);
74   }
75 }
76
77
Popular Tags