Mybatis foreach update problem

<update id="updateList"  parameterType="java.util.List">
    <foreach collection="list" item="item">
        update message set isread=-sharp{item.isread} where id = -sharp{item.id};
    </foreach>
</update>

when you batch update in this way, when there is only one list, it is normal, but when you have more than one piece of data in list, there will be more than one single quotation mark when the id parameter is set to the second entry. Why? No reason found

clipboard.png

Jan.31,2022

Note that the last quotation mark of your error is the quotation mark after near, not your sql quotation mark.


if the < set > < / set > syntax is used, we need to actively set batch updates to mysql. We need to add & allowMultiQueries=true
to the connection address of the configuration database. For more information, please see https://www.jianshu.com/p/feb.

.

verified

Menu