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日