当前位置:   article > 正文

Cause: java.lang.ClassCastException: java.lang.Integer cannot be cast to java.lang.Long_mybatis cause: java.lang.classcastexception: java,

mybatis cause: java.lang.classcastexception: java,lang.integer cannot be cas

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>
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15

错的是user的接口类。

@Mapper
@Repository
public interface MallUserMapper {

    MallUser selectByPrimaryId(int id);

}

  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8

把int改为long就行了

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/煮酒与君饮/article/detail/1011955
推荐阅读
相关标签
  

闽ICP备14008679号