mysql - 在 iBatis 中使用多个更新语句时出错
问题描述
我正在<foreach>
标签下执行多个更新语句。在 MySQL 工作台中执行时,查询似乎工作正常。但是在通过springboot应用程序运行时,我面临如下错误:
更新.xml
<update id="saveSeats" parameterType="map" useGeneratedKeys="true">
<foreach collection="seats" item="seat" separator=";">
UPDATE t002_seat_mst SET IS_ASSIGNED=#{seat.isAssigned},TEAM_ID=#{seat.team.teamId} WHERE (SEAT_ID=#{seat.seatId} AND MAP_ID=#{mapId})
</foreach>;
</update>
错误日志
### Error updating database. Cause: java.sql.SQLSyntaxErrorException: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'UPDATE t002_seat_mst SET IS_ASSIGNED=1,TEAM_ID=31 WHERE (SEAT_ID=677 AND MAP_ID=' at line 1
### The error may exist in config/SeatsMapper.xml
### The error may involve com.seat.arrangement.dao.mapper.MapMapper.saveSeats-Inline
### The error occurred while setting parameters
### SQL: UPDATE t002_seat_mst SET IS_ASSIGNED=?,TEAM_ID=? WHERE (SEAT_ID=? AND MAP_ID=?) ; UPDATE t002_seat_mst SET IS_ASSIGNED=?,TEAM_ID=? WHERE (SEAT_ID=? AND MAP_ID=?) ; UPDATE t002_seat_mst SET IS_ASSIGNED=?,TEAM_ID=? WHERE (SEAT_ID=? AND MAP_ID=?) ;
### Cause: java.sql.SQLSyntaxErrorException: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'UPDATE t002_seat_mst SET IS_ASSIGNED=1,TEAM_ID=31 WHERE (SEAT_ID=677 AND MAP_ID=' at line 1
; bad SQL grammar []; nested exception is java.sql.SQLSyntaxErrorException: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'UPDATE t002_seat_mst SET IS_ASSIGNED=1,TEAM_ID=31 WHERE (SEAT_ID=677 AND MAP_ID=' at line 1] with root cause
java.sql.SQLSyntaxErrorException: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'UPDATE t002_seat_mst SET IS_ASSIGNED=1,TEAM_ID=31 WHERE (SEAT_ID=677 AND MAP_ID=' at line 1
解决方案
推荐阅读
- reactjs - 单击项目后尝试隐藏导航栏的问题(引导程序 5 反应)
- apache-flink - 梁流水线作业未提交给 flink jobmanager
- python - OpenCV 视频捕获不起作用,ret 为 False,帧为“无”
- roblox - 我的脚本不起作用,我该如何使它起作用?
- javascript - MongoDB 中的 $set 是什么?
- django - 如何被选中从多个循环
在 Django 模板中 - jenkins - 使用詹金斯管道定义环境变量时出错
- c++ - UInstancedStaticMeshComponent 在虚幻引擎蓝图中有空的详细信息选项卡
- python - 如何在 django 中创建记录队列?
- python - 仅围绕非零值进行卷积?