example.cmp.basic
Interface Course

All Superinterfaces:
javax.ejb.EJBLocalObject

public interface Course
extends javax.ejb.EJBLocalObject

Local interface for a course taught at Hogwarts, providing methods to view and change it.

 CREATE TABLE basic_courses (
   course_id VARCHAR(250) NOT NULL,
   teacher VARCHAR(250),
 
   PRIMARY KEY(course_id)
 );
 

All Course instances are obtained from the CourseHome interface, and all access to the Course table occurs through the Course interface. Clients can never use the CourseBean implementation directly or directly access the database for the course table. Because Resin-CMP has complete control over the database's course entries, it can more effectively cache results, often avoiding slow database access.

CourseId is the bean's primary key. Every entity bean must have a primary key. There is a setInstructor mutator, but no setCourseId mutator because clients can't set the primary key. Resin-CMP needs to implement the setCourseId method that has been defined in the implementation class,CourseBean.java. But the Implementation Class is not associated with any particular entities -- it is only used by the container to implement the Local Interface. If you want to use a method from the implementation class when calling from a client, it has to be made available explicitly in the Local Interface.


Method Summary
 java.lang.String getCourseId()
          Returns the ID of the course (CMP field).
 java.lang.String getInstructor()
          Returns the instructor's name (CMP field).
 void setInstructor(java.lang.String instructor)
          Sets the instructor's name (CMP field).
 void swap(Course course)
          Swaps the instructor for a course.
 
Methods inherited from interface javax.ejb.EJBLocalObject
getEJBLocalHome, getPrimaryKey, isIdentical, remove
 

Method Detail

getCourseId

public java.lang.String getCourseId()
Returns the ID of the course (CMP field). This is also the primary key as defined in ejb-jar.xml. There's no corresponding setCourseId method in the local interface because clients must not change the primary key.

getInstructor

public java.lang.String getInstructor()
Returns the instructor's name (CMP field). More sophisticated applications will create a separate entity bean for the instructor instead of using a string. The more sophisticated application will use a relationship field to manage the instructor for a course.
See Also:
example.cmp.one2one

setInstructor

public void setInstructor(java.lang.String instructor)
Sets the instructor's name (CMP field).
Parameters:
instructor - the name of the new instructor.

swap

public void swap(Course course)
Swaps the instructor for a course. This business method will run in a transaction, like all business methods in an entity bean. The transaction protects the database from inconsistency when several clients try to modify the database simultaneously.
Parameters:
course - the course which will swap instructors.