mybatis-Mapper记录说明
jar
compile('tk.mybatis:mapper:3.4.0')
关于数据库里为timestamp类型,而类字段为util.Date的数据的转换处理
- 如果未做处理,在做select操作时会报错,报告没有对应的构造函数,如下所示:
org.mybatis.spring.MyBatisSystemException: nested exception is org.apache.ibatis.executor.ExecutorException: No constructor found in net.mrpotato.model.CsUser matching [java.lang.Integer, java.lang.String, java.lang.String, java.lang.String, java.lang.Integer, java.lang.Integer, java.lang.String, java.lang.String, java.lang.String, java.sql.Timestamp, java.sql.Timestamp, java.lang.String]
- 解决方法就是增加默认构造函数和对应的构造函数,如下所示:
public CsUser() {
}
@ConstructorProperties({"id", "password", "nickname", "loginname", "mobile", "telephone", "email", "image", "realNameUser", "createTime", "updateTime", "delFlag"})
public CsUser(Long id, String password, String nickname, String loginname, Integer mobile, Integer telephone, String email, String image, String realNameUser, Timestamp createTime, Timestamp updateTime, String delFlag) {
this.id = id;
this.password = password;
this.nickname = nickname;
this.loginname = loginname;
this.mobile = mobile;
this.telephone = telephone;
this.email = email;
this.image = image;
this.realNameUser = realNameUser;
this.createTime = createTime;
this.updateTime = updateTime;
this.delFlag = delFlag;
}