-
Notifications
You must be signed in to change notification settings - Fork 47
Open
Description
表结构
DROP TABLE IF EXISTS `t_user`;
CREATE TABLE `t_user` (
`id` int(11) UNSIGNED NOT NULL AUTO_INCREMENT,
`username` varchar(20) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL,
`password` varchar(50) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL,
`email` varchar(50) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL,
`activated` tinyint(1) NULL DEFAULT 0,
PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 7 CHARACTER SET = utf8 COLLATE = utf8_general_ci ROW_FORMAT = Dynamic;
SET FOREIGN_KEY_CHECKS = 1;User模型
@Table(name = "t_user")
public class User extends Model {
private Integer id;
private String username;
private String password;
private String email;
private boolean activated;
public User(String username, String password, String email) {
this.username = username;
this.password = password;
this.email = email;
}
public String getEmail() {
return email;
}
public void setEmail(String email) {
this.email = email;
}
public Integer getId() {
return id;
}
public void setId(Integer 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 getActivated() { return activated; }
public void setActivated(boolean activated) { this.activated = activated; }
@Override
public String toString() {
return "User{" +
"id=" + id +
", username='" + username + '\'' +
", password='" + password + '\'' +
", email='" + email + '\'' +
", activated=" + activated +
'}';
}
}例如执行:
user.setActivated(true);
user.update();
在执行完update之后,user模型的Id属性被置为NULL
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels