tk.mybatis通用插件updateByPrimaryKeySelective无法更新数据库

今天在SSM框架中使用Mybatis的tk.mybatis通用插件时,使用updateByPrimaryKeySelective方法更新数据库表失败

Preparing: UPDATE User SET id = ?, email = ?, password = ?, phone = ?, nick_Name = ?, state = ?, img_Url = ?, enable = ? WHERE id = ? AND email = ? AND password = ? AND phone = ? AND nick_Name = ? AND state = ? AND img_Url = ? AND enable = ? 
Parameters: 7(Long), 123456@qq.com(String), 123456450654(String), 15648948(String), sdfsfd(String), 1(String), /img(String), 0(String), 7(Long), 123456@qq.com(String), 123456450654(String), 15648948(String), sdfsfd(String), 1(String), /img(String), 0(String)
Updates: 0

可以看到生成的sql语句中where 后除了id还有其他字段???导致更新失败

解决办法:原来是在实体类中的主键id字段没有加@id注解,导致找不到主键,在id前加上@id注解,问题成功解决

你可能感兴趣的:(通用mapper,mybatis)