tk.mybatis selectByPrimaryKey无法正确识别主键

selectByPrimaryKey无法正确识别主键,查看日志,发现报如下错误:

==> Preparing: SELECT username,password,name,age,sex,birthday,created,updated FROM tb_user WHERE username = ? AND password = ? AND name = ? AND age = ? AND sex = ? AND birthday = ? AND created = ? AND updated = ?
==> Parameters: 1(Long), 1(Long), 1(Long), 1(Long), 1(Long), 1(Long), 1(Long), 1(Long)

解决方案如下:

1、主键的字段上导包错误,应该导入 import javax.persistence.Id

2、主键的数据类型要写成包装类类型,比如是自增id的数据类型为Long,不是long

纪念这个错误。

原文地址:https://www.cnblogs.com/stamina/p/13303974.html