赞
踩
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就行了
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。