Hello,
I have used session facade in my project. A session bean lookups an entity bean for the getting / setting of the data. However, there are more than 20 variables in the entity bean, that means I have used more than 20 setxxx or getxxx methods for a record in the session bean. I know this increase the database traffic, so I try to use value object
pattern in my entity bean. However, I met difficulties to create the entity bean as value object. I can't find any detailed source code for this --
for example,
the code of the value object:
public class PartsVO implements java.io.Serializable {
public
String partsID, partsName, desc;
public PartsVO(PartsVO parts) {
init(parts.partsID, parts.partsName, parts.desc;
}
public void init(String partsID, String partsName, Strign desc) {
this.partsID = partsID;
this.partsName = partsName;
this.desc = desc;
}
public PartsVO getData() {
return new PartsVO(this);
}
}
1) In this case, the entity bean subclasses the value object. How should I implement the entity bean (PartsDataBean)?
public class PartsDataBean extends PartsVO implements javax.ejb.EntityBean {
EntityContext entityContext;
public PartsDataPK ejbCreate(String projID) throws CreateException {
// how should I implement here?
}
public void ejbPostCreate(String projID) throws CreateException {
}
// other
ejb methods
// should I need the following code?
public abstract void setProjID(String projID);
public abstract String getProjID();
public abstract void setProjName(String projName);
public abstract String getProjName();
public abstract void setDesc(String desc);
public abstract String getDesc();
}
2) How about the PartsData and PartsDataHome?
3) Moreover, there are some finder methods in the bean... is there any difference to implement it?
Thanks!
Leyland