LuvI~ 2023-01-25 17:49 采纳率: 0%
浏览 17

myabtis 批量更新报错

mybatis 批量更新传入字符串数组,报错(求解决)

Error updating database. Cause: java.lang.ClassCastException: class [Ljava.lang.String; cannot be cast to class java.util.List ([Ljava.lang.String; and java.util.List are in module java.base of loader 'bootstrap')
The error may exist in file [D:\idea01\crm\crm\demo\target\classes\mapper\TRoleMapper.xml]
The error may involve com.example.demo.dao.TRoleDao.updateDel
The error occurred while executing an update
Cause: java.lang.ClassCastException: class [Ljava.lang.String; cannot be cast to class java.util.List ([Ljava.lang.String; and java.util.List are in module java.base of loader 'bootstrap')] with root cause

java.lang.ClassCastException: class [Ljava.lang.String; cannot be cast to class java.util.List ([Ljava.lang.String; and java.util.List are in module java.base of loader 'bootstrap')

img

img

  • 写回答

2条回答 默认 最新

  • 阳光宅男xxb 2023-01-25 18:35
    关注

    你的写法不对哦,应该是这样写的,请参考这个例子修改下:

    <update id="updateBatch"  parameterType="java.util.List">  
        <foreach collection="list" item="item" index="index" open="" close="" separator=";">
            update course
            <set>
                name=${item.name}
            </set>
            where id = ${item.id}
        </foreach>      
    </update>
    
    评论

报告相同问题?

问题事件

  • 创建了问题 1月25日

悬赏问题

  • ¥15 is not in the mmseg::model registry。报错,模型注册表找不到自定义模块。
  • ¥15 安装quartus II18.1时弹出此error,怎么解决?
  • ¥15 keil官网下载psn序列号在哪
  • ¥15 想用adb命令做一个通话软件,播放录音
  • ¥30 Pytorch深度学习服务器跑不通问题解决?
  • ¥15 部分客户订单定位有误的问题
  • ¥15 如何在maya程序中利用python编写领子和褶裥的模型的方法
  • ¥15 Bug traq 数据包 大概什么价
  • ¥15 在anaconda上pytorch和paddle paddle下载报错
  • ¥25 自动填写QQ腾讯文档收集表