モデル類(貧血モデル、充血モデル)
1507 ワード
1.貧血モデル
2.充血モデル(exists()が多くなったような方法)
package cn.com.lrs.model;
public class User {
private int id;
private String username;
private String password;
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
public String getUsername() {
return username;
}
public void setUsername(String username) {
this.username = username;
}
public String getPassword() {
return password;
}
public void setPassword(String password) {
this.password = password;
}
}
2.充血モデル(exists()が多くなったような方法)
package cn.com.lrs.model;
import cn.com.lrs.service.UserManager;
public class User {
private int id;
private String username;
private String password;
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
public String getUsername() {
return username;
}
public void setUsername(String username) {
this.username = username;
}
public String getPassword() {
return password;
}
public void setPassword(String password) {
this.password = password;
}
public boolean exists() throws Exception {
return new UserManager().exists(this);
}
}