请根据下面的建表语句,创建一个POJO实体类,如下:CREATE TABLE `points` ( `id` BIGINT(20) NOT NULL AUTO_INCREMENT COMMENT '积分表ID', `user_id` BIGINT(20) NOT NULL COMMENT '用户ID', `username` BIGINT(20) NOT NULL COMMENT '用户名', `email` BIGINT(20) DEFAULT NULL COMMENT '邮箱', `points` TINYINT(4) NOT NULL COMMENT '积分', PRIMARY KEY (`id`), UNIQUE KEY `unique_point` (`user_id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='积分表';
时间: 2023-06-11 12:09:42 浏览: 90
根据以上建表语句,可以创建如下的POJO实体类:
```java
public class Points {
private Long id;
private Long userId;
private String username;
private String email;
private Integer points;
public Points() {}
public Points(Long userId, String username, String email, Integer points) {
this.userId = userId;
this.username = username;
this.email = email;
this.points = points;
}
// getter and setter methods
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
public Long getUserId() {
return userId;
}
public void setUserId(Long userId) {
this.userId = userId;
}
public String getUsername() {
return username;
}
public void setUsername(String username) {
this.username = username;
}
public String getEmail() {
return email;
}
public void setEmail(String email) {
this.email = email;
}
public Integer getPoints() {
return points;
}
public void setPoints(Integer points) {
this.points = points;
}
}
```
该实体类对应了建表语句中的所有字段,并且提供了相应的setter和getter方法。需要注意的是,建表语句中的`id`字段为自增长字段,因此在实体类中只需要提供setter和getter方法即可,无需在构造函数中初始化。
阅读全文