value Object code snippet for Company public class CompanyStruct implements java.io.Serializable { public Integer comId; public String comName; public String comDescription; public Timestamp mutationDate; public void copyFrom(CompanyStruct struct) { comId = struct.comId; comName = struct.comName; comDescription = struct.comDescription; mutationDate = struct.mutationDate; } } |
Code snippet for an Entity Bean’s getData() public CompanyStruct getData() { CompanyStruct result = new CompanyStruct(); result.copyFrom(this); return result; } |
Code snippet for an Entity Bean’s setData() public void setData(CompanyStruct struct) { this.copyFrom(struct); } |
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; } } |
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 } |
public void ejbLoad() { try { comId=(company == null)?null:(Integer)company.getPrimaryKey(); } catch (Exception e) { //throw some runtime exception (e.g. EJBException) } } |
public void ejbStore() { try { company = (comId == null)?null:beanGlossary.getCompanyHome().findByPrimary Key(comId); } catch (Exception e) { //throw some runtime exception (e.g. EJBException) } } |
本站部分信息来自互联网,如果您认为本站有侵犯您权益的内容,请及时通知我们,我们会作出适当的处理。 E-Mail:nihao@foxmail.com 合作QQ:80044735 Copyright@ 2018 湛江热线 版权所有 ![]() |