KickJava   Java API By Example, From Geeks To Geeks.

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


1 package example.cmp.xdoclet;
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 xdoclet_students (
12  * name VARCHAR(250) NOT NULL,
13  *
14  * PRIMARY KEY(name)
15  * );
16  * </code></pre>
17  *
18  * @ejb:bean name="xdoclet_StudentBean" view-type="local" type="CMP"
19  * reentrant="False" schema="students" primkey-field="name"
20  * @ejb:pk class="java.lang.String"
21  * @ejb:home generate="local" local-class="example.cmp.xdoclet.StudentHome"
22  * @ejb:interface generate="local" local-class="example.cmp.xdoclet.Student"
23  *
24  * @ejb:finder signature="java.util.Collection findAll()"
25  * query="SELECT s FROM students s ORDER BY s.name"
26  *
27  * @ejb:finder signature="java.util.Collection findByCourse(java.lang.String course)"
28  * query="SELECT s FROM courses course, IN(course.studentList) s WHERE course.name = ?1"
29  *
30  * @resin-ejb:entity-bean sql-table="xdoclet_students"
31  */

32 abstract public class StudentBean extends com.caucho.ejb.AbstractEntityBean
33 {
34   /**
35    * A Student is identified by name.
36    *
37    * @ejb:interface-method
38    * @ejb:persistent-field
39    * @ejb:pk-field
40    */

41   abstract public String getName();
42
43   /**
44    * Returns a Collection of Courses which this Student is taking.
45    *
46    * @ejb:interface-method
47    * @ejb:relation name="xdoclet_enrollment" role-name="student"
48    *
49    * @resin-ejb:relation sql-column="student"
50    */

51   abstract public Collection getCourseList();
52   
53   /**
54    * Enrolls this Student in a Course.
55    *
56    * @ejb:interface-method
57    */

58   public void addCourse(Course course)
59   {
60     getCourseList().add(course);
61   }
62   
63   /**
64    * Drops this Student from a Course.
65    *
66    * @ejb:interface-method
67    */

68   public void removeCourse(Course course)
69   {
70     getCourseList().remove(course);
71   }
72 }
73
Popular Tags