首页 新闻 会员 周边

mybatis异常

0
悬赏园豆:15 [已解决问题] 解决于 2018-06-23 13:22

xml配置如下:

<update id="updateUsers" parameterType="java.util.List">
 <foreach collection="users" item="item" index="index" open="" close="" separator=";">
update user
<set>
parent_id = 0
</set>
where id = ${item.id} and bjid = ${item.bjid} and njid = ${item.njid}
</foreach>
</update>

mapper如下:
Integer updateUsers(@Param("users") List<user> users);

调用:
userDao.updateUsers(userList);

异常信息如下:
org.mybatis.spring.MyBatisSystemException:nested exception is org.apache.ibatis.exceptions.PersistenceException: \n### Error updating database. Cause: java.lang.ClassCastException: java.lang.Integer cannot be cast to java.lang.Long\n### The error may involve com.kjm.calm.mmapper.UserDao.updateUserInfo-Inline\n### The error occurred while setting parameters\n### SQL: \n### Cause: java.lang.ClassCastException: java.lang.Integer cannot be cast to java.lang.Long


        
横槊的主页 横槊 | 初学一级 | 园豆:12
提问于:2018-06-21 12:46
< >
分享
最佳答案
0

updateUserInfo中参数类型错误,integer转long报错,异常中说了

收获园豆:15
小光 | 小虾三级 |园豆:1766 | 2018-06-21 16:33
其他回答(2)
0

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

Integer updateUsers(@Param("users") List<user> users); 改成
Long updateUsers(@Param("users") List<user> users);

、熙和 | 园豆:1508 (小虾三级) | 2018-06-21 16:43
0

已解决。原因是传入的参数list size为0,在调用前判空就可以了。

横槊 | 园豆:12 (初学一级) | 2018-06-23 13:22
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册