象以前, Entity Bean從結構繼續,下面是公司Entity Bean的代碼片段: public class CompanyBean extends CompanyStrUCt implements EntityBean { EntityContext entityContext; // CMP for all fields in the CompanyStruct public java.util.Collection employees; //one-to-many //rest of the code including getData() and setData() public java.util.Collection getEmployees() { return employees; } }
下面是雇員Entity Bean的程序片段: public class EmployeeBean extends EmployeeStruct implements EntityBean { EntityContext entityContext; //CMP for all fields in EmployeeStruct EXCEPT //the comId public Company company;//remote reference to company }