Certification
SCBCDSCBCD Study Notes : Chapter 6 : Component Contract for Container-Managed Persistence (CMP) (Part 4)
Please find the Study Notes and resources which covers the 4th Part of Chapter 6 : Component Contract for Container-Managed Persistence (CMP), as part of the Sun Certified Business Component Developer exam CX-310-090.
6. Identify the interfaces and methods a CMP entity bean must and must not implement.
Chapter 6 : Component Contract for Container-Managed Persistence (CMP) (Part 4)
Identify the interfaces and methods a CMP entity bean must and must not implement.
The following are the requirements for an entity bean class:
.
.
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
public interface EntityBean extends EnterpriseBean { ;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;void ejbActivate() throws EJBException, RemoteException; ;;;;;;;;;;;;;;
;;;;;;;void ejbLoad() throws EJBException, RemoteException; ;;;;;;;;;;;;;;l;;;
;;;;;;;void ejbPassivate() throws EJBException, RemoteException; ;;;;;;;;;l;;;
;;;;;;;void ejbRemove() throws RemoveException, EJBException, RemoteException;
;;;;;;;void ejbStore() throws EJBException, RemoteException; ;;;;;;;;;l;;;;;;;
;;;;;;;void setEntityContext(EntityContext ctx) throws EJBException, ;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;RemoteException;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;void unsetEntityContext() throws EJBException, RemoteException; ;;;;;;;
} ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
public interface EnterpriseBean extends Serializable { ;;;;;;;;;;;;;;;;;;;;;;;
} ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
The following are the requirements for a dependent value class:
The entity bean class MUST implement the ejbCreate< METHOD >(...) methods that correspond to the create< METHOD >(...) methods specified in the entity bean’s home interface.
The entity bean class may define ZERO or more ejbCreate< METHOD >(...) methods whose signatures must follow these rules:
For each ejbCreate< METHOD >(...) method, the entity bean class MUST define a matching ejbPostCreate< METHOD >(...) method, using the following rules:
The entity bean class may define ZERO or more HOME methods whose signatures must follow the following rules:
The entity bean class may define one or more SELECT methods whose signatures must follow the following rules:
The entity bean class may define ZERO or more BUSINESS methods whose signatures must follow these rules:
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
public abstract class AddressBean implements javax.ejb.EntityBean { ;;;;;;;;;;
;;;;;;;... ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;public Integer ejbCreateAddress(String street, String city, ;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;String state, String zip) throws CreateException {
;;;;;;;;;;;;;;;;;;setId(..); ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;setStreet(..); ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;setCity(..); ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;... ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;return null; // for CMP 2.x !!! ;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;} ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;public void ejbPostCreateAddress(String street, String city, ;;;;;;;;
;;;;;;;;;;;;;;;;;;String state, String zip) { ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;} ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;// persistent fields ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;public abstract Integer getId(); ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;public abstract void setId(Integer id); ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;public abstract String getStreet(); ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;public abstract void setStreet(String street); ;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;public abstract String getCity(); ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;public abstract void setCity(String city); ;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;// ejbSelect methods ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;public abstract Collection ejbSelectZipCodes(String state) ;;;;;;;;;;
;;;;;;;;;;;;;;;;;;throws FinderException; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;public abstract Collection ejbSelectAll() ;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;throws FinderException; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;public abstract CustomerLocal ejbSelectCustomer(AddressLocal addr) ;;
;;;;;;;;;;;;;;;;;;throws FinderException; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;// customer home methods. These are wrappers of ejbSelect methods ;;;
;;;;;;;;;public Collection ejbHomeQueryZipCodes(String state) ;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;throws FinderException { ;;;;;;;;;;;;;;;;;;;;;;;;;l
;;;;;;;;;;;;;;;;;;return ejbSelectZipCodes(state); ;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;} ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;public Collection ejbHomeQueryAll() ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;throws FinderException { ;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;return ejbSelectAll(); ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;} ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;public CustomerLocal ejbHomeQueryCustomer(AddressLocal addr) ;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;throws FinderException { ;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;return ejbSelectCustomer(addr); ;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;} ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;// standard call back methods ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;public void setEntityContext(EntityContext ec){} ;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;public void unsetEntityContext(){} ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;public void ejbLoad(){} ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;public void ejbStore(){} ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;public void ejbActivate(){} ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;public void ejbPassivate(){} ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;public void ejbRemove(){} ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
} ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
< entity > ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;< ejb-name >AddressEJB< /ejb-name > ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;... ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;< prim-key-class >java.lang.Integer< /prim-key-class > ;;;;;;;;;;;;;;;;
;;;;;;;< reentrant >False< /reentrant > ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;< cmp-version >2.x< /cmp-version > ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;< abstract-schema-name >Address< /abstract-schema-name > ;;;;;;;;;;;;;;
;;;;;;;< cmp-field >< field-name >id< /field-name >< /cmp-field > ;;;;;;;;;;;;
;;;;;;;< cmp-field >< field-name >street< /field-name >< /cmp-field > ;;;;;;;;
;;;;;;;... ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;< primkey-field >id< /primkey-field > ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;< security-identity >< use-caller-identity/ >< /security-identity > ;;;
;;;;;;;< query > ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;< query-method > ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;< method-name >ejbSelectZipCodes< /method-name > ;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;< method-params > ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;< method-param >java.lang.String< /method-param >
;;;;;;;;;;;;;;;;;;;;;< /method-params > ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;< /query-method > ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;< ejb-ql > ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;SELECT a.zip FROM Address AS a ;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;WHERE a.state = ?1 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;< /ejb-ql > ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;< /query > ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;< query > ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;< query-method > ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;< method-name >ejbSelectAll< /method-name > ;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;< method-params/ > ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;< /query-method > ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;< ejb-ql > ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;SELECT OBJECT(a) FROM Address AS a ;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;< /ejb-ql > ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;< /query > ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;... ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
< /entity >;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
________________
Author: Mikalai Zaikin. Please Click Here to visit Authors site for any updates and changes to the study notes.