I'm trying to understand what is required to effectively store
CMP/entity beans that contain references to other CMP/entity beans. Is
it necessary to put the storage and retrieval logic for references to
other CMP/entity beans in the ejbLoad and ejbStore methods?
For example:
If I have a ApplicantEJB and it contains a ResidenceEJB (both EJBs are
CMP). Should I put something similiar to the following in the ejbLoad
method for ApplicantEJB:
public void ejbLoad() throws RemoteException {
//residence is an instance variable of ApplicantEJB
try {
Context context = new InitialContext();
ResidenceHome residenceHome = (ResidenceHome)
context.lookup("java:comp/env/Residence");
residence = residenceHome.findByPrimaryKey(this.id);
if(residence == null) {
System.out.println("Residence not found so creating new
one");
residence =
(Residence)PortableRemoteObject.narrow(residenceHome.create(this.id),
Residence.class);
}
}
catch(Exception e) {
throw new RemoteException(e.toString());
}
}
Am I on the right track?
Thanks,
Micah Skilling.
ps. Orion is a blast to work with.