example.cmp.find
Interface CourseHome

All Superinterfaces:
javax.ejb.EJBLocalHome

public interface CourseHome
extends javax.ejb.EJBLocalHome

Home interface for the Course bean. The home interface for the Course bean. The home interface enables you to create new entities and to obtain references to existing ones using find methods.

The home interface enables you to create new entities and to obtain references to existing ones.

The idea is that you use the Home Interface to obtain references to whatever entities you're interested in. Each entity that you

Applications use the Home Interface to obtain references to whatever entities it needs. Each entity that you get from the Home Interface (using its create or finder methods) is then accessible through its Local Interface.


Method Summary
 java.util.Collection findAll()
          Returns a Collection of all Course entities in the database.
 Course findByInstructor(java.lang.String instructorName)
          Returns the Course taught by the indicated instructor.
 Course findByPrimaryKey(java.lang.String courseId)
          Returns the Course that has courseId as its primary key.
 
Methods inherited from interface javax.ejb.EJBLocalHome
remove
 

Method Detail

findByInstructor

public Course findByInstructor(java.lang.String instructorName)
                        throws javax.ejb.FinderException
Returns the Course taught by the indicated instructor. This is an example of a finder method that returns a single entity. If no courses match or if multiple classes match, the find method will throw an exception.

The return type is the local interface of the bean. Find methods always return a single instance of the local interface or a collection of the local interfaces. Applications which need to return other entity bean interfaces or values must use ejbSelect methods in the bean implementation.

The find method's query is specified in the deployment descriptor in the <query> tag using EJB-QL. "?1" refers to the first method argument. find_courses is the abstract-schema-name in the deployment descriptor. This may differ from the actual SQL table if sql-table-name has been specified.

 SELECT o FROM find_courses o WHERE o.instructor = ?1
 

Resin-CMP will generate the code and SQL for the find method.

Parameters:
instructorName - name of the instructor who teaches the Course we want to find.
Throws:
ObjectNotFoundException - if there is no matching course.
javax.ejb.FinderException - if there are more than one matching courses.

findAll

public java.util.Collection findAll()
                             throws javax.ejb.FinderException
Returns a Collection of all Course entities in the database. This is an example of a finder method that returns a Collection of entities.

Resin-CMP will implement this method. All we have to provide is this declaration, and a <query> section in the deployment descriptor.

 SELECT o FROM find_courses o
 

findByPrimaryKey

public Course findByPrimaryKey(java.lang.String courseId)
                        throws javax.ejb.FinderException
Returns the Course that has courseId as its primary key.

Every entity EJB needs to define this finder method that looks for an entity based on the primary key.

Parameters:
courseId - the primary key of the course
Returns:
the matching course
Throws:
ObjectNotFoundException - if there is no course matching the key.