在写select的时候…突然发现…那个老问题…
如何把持久化类设计好的问题..是不断的向其它字段增加很多其它类的属性(如果有需要的话)还是直接在类里面增加一个类的属性…好比:
public class UserVO {
private int userId;
private String userName;
private String userTitle;
private String userPasswd;
private PhoneVO userPhone;
private PhoneVO userCell;
private String userEmail;
private String updateBy;
private AreaVO area;
private RoleVO role;
/**
* @return
*/
public String getUpdateBy() {
if (updateBy != null)
return updateBy;
else
return "";
}
private int userId;
private String userName;
private String userTitle;
private String userPasswd;
private PhoneVO userPhone;
private PhoneVO userCell;
private String userEmail;
private String updateBy;
private AreaVO area;
private RoleVO role;
/**
* @return
*/
public String getUpdateBy() {
if (updateBy != null)
return updateBy;
else
return "";
}
/**
* @param createdBy
*/
public void setUpdateBy(String updateBy) {
this.updateBy = updateBy;
}
里面塞的对象PhoneVO:
public class PhoneVO {
private String areaCode;
private String phoneNumber;
private String extension;
public PhoneVO() {
areaCode="";
phoneNumber = "";
extension = "";
}
{
其实这样的设计不错…不过就是new多了一点:)梁总以前的代码那样做是简单…可实现了想要的功能.只不过设计的不太合理罢了….
通过在csdn和32302474和xboy的指点终于决定应该按照刚刚代码那样去写!还是很有条理的…况且hibernate书上也推荐这么做…
PS:不要惧怕争论…争论过后总会有点收获…