|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
example.cmp.basic.CourseBean
Implementation class for the Course bean.
The implementation class of the Course
entity bean.
Its methods will be called only by the EJB container, never directly
by clients. Clients always call methods in the local interface, calling
methods in the Resin-CMP generated stub. The stub methods will call
the CourseBean methods in the correct transaction context.
AbstractEntityBean
is a convenience superclass
that provides a set of methods required by the spec that we don't use in
this example.
This CMP entity bean use the following schema:
CREATE TABLE basic_courses (
course_id VARCHAR(250) NOT NULL,
instructor VARCHAR(250),
PRIMARY KEY(course_id)
);
The column names are generated from the field names. getCourseId becomes course_id and getInstructor becomes instructor. The table name is specified in the ejb deployment descriptor, cmp-basic.ejb.
Constructor Summary | |
CourseBean()
|
Method Summary | |
abstract java.lang.String |
getCourseId()
Returns the ID of the course, the primary key. |
abstract java.lang.String |
getInstructor()
Returns the name of the instructor for this course. |
abstract void |
setCourseId(java.lang.String courseId)
Sets the primary key of the course, only called from a create method. |
abstract void |
setInstructor(java.lang.String instructor)
Sets the name of the instructor for this course. |
void |
swap(Course course)
Swaps the instructors. |
Constructor Detail |
public CourseBean()
Method Detail |
public abstract java.lang.String getCourseId()
All container-managed fields are abstract since Resin-CMP will generate the SQL and JDBC calls to manage them.
Each cmp-field described in the deployment descriptor needs to be matched in the implementation class by abstract setXXX and getXXX methods. The container will take care of implementing them.
Note that unless you make these methods available in the local interface, you will never be able to access them from an EJB client such as a servlet.
public abstract void setCourseId(java.lang.String courseId)
courseId
- the courseId of the new coursepublic abstract java.lang.String getInstructor()
Resin-CMP will automatically cache the value so most calls to getInstructor can avoid database calls.
public abstract void setInstructor(java.lang.String instructor)
public void swap(Course course)
Because concurrent modifications can conflict, it's always possible for a business method to throw a transaction failure exception, a runtime exception. Depending on the business logic, clients can retry the transaction or just return an error message.
course
- the course with the instructor to swap.javax.ejb.EJBException
- if the transaction fails.
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |