baomidou / mybatis-plus

An powerful enhanced toolkit of MyBatis for simplify development
https://baomidou.com
Apache License 2.0
16.42k stars 4.31k forks source link

[java.lang.NullPointerException: Cannot invoke "Object.hashCode()" because "key" is null] #6200

Closed bai-xuan closed 5 months ago

bai-xuan commented 5 months ago

mp 版本:3.5.6 jdk: openjdk version "17.0.11" 2024-04-16 OpenJDK Runtime Environment Temurin-17.0.11+9 (build 17.0.11+9) OpenJDK 64-Bit Server VM Temurin-17.0.11+9 (build 17.0.11+9, mixed mode, sharing)

实体类:

import com.baomidou.mybatisplus.annotation.IdType; import com.baomidou.mybatisplus.annotation.TableField; import com.baomidou.mybatisplus.annotation.TableId; import com.baomidou.mybatisplus.annotation.TableName; import com.baomidou.mybatisplus.extension.activerecord.Model; import lombok.Data; import lombok.EqualsAndHashCode;

import java.io.Serializable; import java.util.Date;

@Data @EqualsAndHashCode(callSuper = false) @TableName("test") public class User extends Model {

private static final long serialVersionUID = 1L;

/**
 * id
 */
@TableId(value = "id", type = IdType.AUTO)
private Long id;

/**
 * 用户名
 */
@TableField("user_name")
private String userName;

/**
 * 用户名
 */
@TableField("nick_name")
private String nickName;

/**
 * 性别
 */
@TableField("sex")
private Integer sex;

/**
 * 头像
 */
@TableField("head_image")
private String headImage;

/**
 * 头像缩略图
 */
@TableField("head_image_thumb")
private String headImageThumb;

/**
 * 个性签名
 */
@TableField("signature")
private String signature;
/**
 * 密码(明文)
 */
@TableField("password")
private String password;

/**
 * 最后登录时间
 */
@TableField("last_login_time")
private Date lastLoginTime;

/**
 * 创建时间
 */
@TableField("created_time")
private Date createdTime;

/**
 * 注册来源:0本系统,1gitee,2github
 */
@TableField("register_from")
private Integer registerFrom;

/**
 * oauth认证结果
 */
@TableField("oauth_src")
private String oauthSrc;

/**
 * 账号类型:0正常,1匿名
 */
@TableField("account_type")
private Integer accountType;

/**
 * 匿名id
 */
@TableField("anonymou_id")
private String anonymouId;

@TableField("last_login_ip")
private String lastLoginIp;

@Override
protected Serializable pkVal() {
    return this.id;
}

}

如何出现的,问题代码: User user = lambdaQuery().eq(User::getAnonymouId, req.getAnonymouId()).one(); image

nieqiurong commented 5 months ago

复现工程示例.

bai-xuan commented 5 months ago

已找到问题,引入了低版本的mybatis-plus-extension包