Cause: java.lang.ClassCastException: java.lang.Integer cannot be cast to java.lang.Long

Could not set parameters for mapping: ParameterMapping{property=‘userId’, mode=IN, javaType=class java.lang.Long, jdbcType=BIGINT, numericScale=null, resultMapId=‘null’, jdbcTypeName=‘null’, expression=‘null’}. Cause: org.apache.ibatis.type.TypeException: Error setting non null for parameter #1 with JdbcType BIGINT . Try setting a different JdbcType for this parameter or a different configuration property. Cause: java.lang.ClassCastException: java.lang.Integer cannot be cast to java.lang.Long

org.mybatis.spring.MyBatisSystemException: nested exception is org.apache.ibatis.type.TypeException: Could not set parameters for mapping: ParameterMapping{property=‘userId’, mode=IN, javaType=class java.lang.Long, jdbcType=BIGINT, numericScale=null, resultMapId=‘null’, jdbcTypeName=‘null’, expression=‘null’}. Cause: org.apache.ibatis.type.TypeException: Error setting non null for parameter #1 with JdbcType BIGINT . Try setting a different JdbcType for this parameter or a different configuration property. Cause: java.lang.ClassCastException: java.lang.Integer cannot be cast to java.lang.Long

类型问题:我的数据库里的user_id字段是bigint型的,
我的映射文件写的没错,

<resultMap id="BaseResultMap" type="com.kenny.pojo.MallUser">
        <id column="user_id" jdbcType="BIGINT" property="userId"/>
        <result column="nick_name" jdbcType="VARCHAR" property="nickName"/>
        <result column="login_name" jdbcType="VARCHAR" property="loginName"/>
        <result column="password_md5" jdbcType="VARCHAR" property="passwordMd5"/>
        <result column="introduce_sign" jdbcType="VARCHAR" property="introduceSign"/>
        <result column="address" jdbcType="VARCHAR" property="address"/>
        <result column="is_deleted" jdbcType="TINYINT" property="isDeleted"/>
        <result column="locked_flag" jdbcType="TINYINT" property="lockedFlag"/>
        <result column="create_time" jdbcType="TIMESTAMP" property="createTime"/>
    </resultMap>
    <sql id="Base_Column_List">
        user_id,nick_name,login_name,password_md5,introduce_sign,address,is_deleted,
        locked_flag,create_time
    </sql>

错的是user的接口类。

@Mapper
@Repository
public interface MallUserMapper {

    MallUser selectByPrimaryId(int id);

}

把int改为long就行了

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值