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

就好了

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章