KickJava   Java API By Example, From Geeks To Geeks.

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


1 package example.cmp.xdoclet;
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 xdoclet_courses (
12  * id VARCHAR(250) NOT NULL,
13  * instructor VARCHAR(250),
14  *
15  * PRIMARY KEY(name)
16  * );
17  * </pre></code>
18  *
19  * @ejb:bean name="xdoclet_CourseBean" view-type="local" type="CMP"
20  * reentrant="False" schema="courses" primkey-field="name"
21  * @ejb:pk class="java.lang.String"
22  * @ejb:home generate="local" local-class="example.cmp.xdoclet.CourseHome"
23  * @ejb:interface generate="local" local-class="example.cmp.xdoclet.Course"
24  *
25  * @ejb:finder signature="java.util.Collection findByStudent(java.lang.String student)"
26  * query="SELECT c FROM students student, IN(student.courseList) c WHERE student.name = ?1"
27  *
28  * @ejb:finder signature="java.util.Collection findAll()"
29  * query="SELECT c FROM courses c ORDER BY c.name"
30  *
31  * @ejb:select signature="java.util.Collection ejbSelectAllInstructors()"
32  * query="SELECT c.instructor FROM courses c
33  * WHERE c.instructor IS NOT NULL
34  * ORDER BY c.instructor"
35  *
36  * @resin-ejb:entity-bean sql-table="xdoclet_courses"
37  */

38 abstract public class CourseBean extends com.caucho.ejb.AbstractEntityBean
39 {
40   /**
41    * A Course is identified by its name.
42    *
43    * @ejb:interface-method
44    * @ejb:persistent-field
45    * @ejb:pk-field
46    *
47    * @resin-ejb:cmp-field sql-column="id"
48    */

49   abstract public String getName();
50
51   /**
52    * Returns the name of this Course's instructor.
53    *
54    * @ejb:interface-method
55    * @ejb:persistent-field
56    */

57   abstract public String getInstructor();
58
59   /**
60    * Returns a Collection of Students enrolled in this Course.
61    *
62    * @ejb:interface-method
63    * @ejb:relation name="xdoclet_enrollment" role-name="course"
64    *
65    * @resin-ejb:relation sql-table="xdoclet_enrollment" sql-column="course"
66    */

67   abstract public Collection getStudentList();
68
69   /**
70    * Enrolls a Student is this Course.
71    *
72    * @ejb:interface-method
73    */

74   public void addStudent( Student student )
75   {
76     getStudentList().add( student );
77   }
78
79   /**
80    * Drops a Student from this Course.
81    *
82    * @ejb:interface-method
83    */

84   public void removeStudent( Student student )
85   {
86     getStudentList().remove( student );
87   }
88   
89   /**
90    * Returns the names of all instructors in alphabetical order.
91    */

92   abstract public Collection ejbSelectAllInstructors()
93   throws javax.ejb.FinderException;
94   
95   /**
96    * Returns the names of all instructors in alphabetical order.
97    *
98    * @ejb:home-method view-type="local"
99    */

100   public Collection ejbHomeListAllInstructors()
101   throws javax.ejb.FinderException
102   {
103     return ejbSelectAllInstructors();
104   }
105 }
106
Popular Tags