mybaties批量修改报错

mybatis的批量update操作写法很简单,如下:

public int updateBatchStatus(List<TApiApplyPermission> list)
    {
        return tApiApplyPermissionMapper.updateBatchStatus(list);
    }

 <update id="updateBatchStatus"  parameterType="java.util.List">  
      <foreach collection="list" item="item" index="index" open="" close="" separator=";">
        update t_api_apply_permission set apply_status = 1 
        where apply_id = #{item.applyId} and api_interface_id = #{item.apiInterfaceId}
      </foreach>      
    </update>

在执行过程中报异常,但是sql和参数直接在DB里执行是好的,原因是MySql默认不支持批量更新,需要开发人员主动设置,只需要在你的数据库连接url后面加上

&allowMultiQueries=true

就好了

发布了546 篇原创文章 · 获赞 138 · 访问量 97万+

猜你喜欢

转载自blog.csdn.net/xingxiupaioxue/article/details/105310560