KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > example > cmp > find > CourseHome


1 package example.cmp.find;
2
3 import javax.ejb.CreateException;
4 import javax.ejb.EJBLocalHome;
5 import javax.ejb.EJBHome;
6 import javax.ejb.FinderException;
7
8 import java.util.Collection;
9
10 /**
11  * Home interface for the Course bean.
12  * The home interface for the Course bean. The home interface enables
13  * you to create new entities and to obtain references to existing ones
14  * using find methods.
15  *
16  * <p>The home interface enables you to create new entities and to obtain
17  * references to existing ones.
18  *
19  * <p>The idea is that you use the Home Interface to obtain references
20  * to whatever entities you're interested in. Each entity that you
21  * <p>Applications use the Home Interface to obtain references
22  * to whatever entities it needs. Each entity that you
23  * get from the Home Interface (using its create or finder methods)
24  * is then accessible through its Local Interface.
25  *
26  */

27 public interface CourseHome extends EJBLocalHome {
28   /**
29    * Returns the <code>Course</code> taught by the indicated instructor.
30    * This is an example of a finder method that returns a single
31    * entity. If no courses match or if multiple classes match, the find
32    * method will throw an exception.
33    *
34    * <p>The return type is the local interface of the bean.
35    * Find methods always return a single instance of the local
36    * interface or a collection of the local interfaces. Applications
37    * which need to return other entity bean interfaces or values must
38    * use ejbSelect methods in the bean implementation.
39    *
40    * <p>The find method's query is specified in the deployment descriptor
41    * in the &lt;query> tag using EJB-QL. "?1" refers to the first
42    * method argument. find_courses is the abstract-schema-name in the
43    * deployment descriptor. This may differ from the actual SQL table
44    * if sql-table-name has been specified.
45    *
46    * <code><pre>
47    * SELECT o FROM find_courses o WHERE o.instructor = ?1
48    * </pre></code>
49    *
50    * <p>Resin-CMP will generate the code and SQL for the find method.
51    *
52    * @param instructorName name of the instructor who teaches
53    * the <code>Course</code>
54    * we want to find.
55    *
56    * @exception ObjectNotFoundException if there is no matching course.
57    * @exception FinderException if there are more than one matching courses.
58    */

59   public Course findByInstructor(String instructorName)
60     throws FinderException;
61
62   /**
63    * Returns a Collection of all <code>Course</code> entities in the database.
64    * This is an example of a finder method that returns a Collection of
65    * entities.
66    *
67    * <p>Resin-CMP will implement this method. All we have to provide is this
68    * declaration, and a <code>&lt;query></code> section in the deployment
69    * descriptor.
70    *
71    * <code><pre>
72    * SELECT o FROM find_courses o
73    * </pre></code>
74    */

75   public Collection findAll()
76     throws FinderException;
77
78   /**
79    * Returns the <code>Course</code> that has <code>courseId</code>
80    * as its primary key.
81    *
82    * <p>Every entity EJB needs to define this finder method that looks for an
83    * entity based on the primary key.
84    *
85    * @param courseId the primary key of the course
86    * @return the matching course
87    *
88    * @exception ObjectNotFoundException if there is no course matching the key.
89    */

90   Course findByPrimaryKey(String courseId)
91     throws FinderException;
92 }
93
Popular Tags