1 package example.cmp.ejbql; 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 enables you to create new entities and to obtain 13 * references to existing ones. 14 * 15 * <p>The CourseHome example provides two finder methods: the standard 16 * findByPrimaryKey and a findByHouse method. Find methods for a local 17 * home always return the local interface or a collection of 18 * the local interface. 19 * 20 * <p/>All find methods except findByPrimaryKey need an EJB-QL query in 21 * the deployement descriptor. 22 */ 23 public interface CourseHome extends EJBLocalHome { 24 /** 25 * This is an example of a finder method that returns a single entity if 26 * successful, and throws an <code>ObjectNotFoundException</code> if it 27 * was unsuccessful. 28 * Every entity EJB needs to define this finder method that looks for an 29 * entity based on the primary key. 30 */ 31 Course findByPrimaryKey(String primaryKey) 32 throws FinderException; 33 34 /** 35 * Finds all the courses for the students living in a house. The example 36 * methods shows how a query can use the IN(...) expression to select 37 * a collection of entities. 38 * 39 * <code><pre> 40 * SELECT DISTINCT OBJECT(course) 41 * FROM ejbql_student student, IN(student.courseList) course 42 * WHERE student.house.name=?1 43 * </pre></code> 44 * 45 * @param house the name of the student's house. 46 * 47 * @return the matching collection of courses. 48 */ 49 Collection findByHouse(String house) 50 throws FinderException; 51 } 52