异常日志缺失:
org.springframework.jdbc.BadSqlGrammarException:
看两个我写的批量修改的示例:这两个都是正确的,已经在生产环境了 找不同
批量修改1
<update id="batchUpdateBooksDetailRelation" parameterType="org.yungu.read.entity.BooksDetailRelation"> <foreach collection="booksDetailRelationList" item="item" separator=";"> update books_detail_relation set status = #{item.status} where detail_id = #{item.detailId} and book_id = #{item.bookId} </foreach> </update>
批量修改的2
<update id="batchUpdateBooks" parameterType="org.yungu.read.entity.Books"> <foreach collection="booksList" item="item" open="(" separator="," close=")"> update books set book_name = #{item.bookName}, file_id = #{item.fileId}, author = #{item.author}, modify_time = #{item.modifyTime} where id = #{item.id} </foreach> </update>
原因:
本次的异常是我在第一个批量修改中遇到的,对比发现了,第一个没有写开始的(没有写结束的),所以导致了语法异常,所以丢一个修改必须使用 ; 才会解决这个异常