开发者社区> 问答> 正文

MYBATIS 批量update 报错的问题 ?报错

批量update,很简单的sql语句,可是一直在报错。不知道为什么,求助!!!

close="" separator=";">
update student_point_level s
set s.score = #{item.score}
where s.id = #{item.id}


按照打印出来的sql,贴到front里运行的也都是对的....

Error updating database. Cause: com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: 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 student_point_level s

        set s.score = 16
        where s.id = 19' at line 7

The error may involve com.supert.st.dao.StudentPointLevelMapper.updateStudentPointLevelBatch-Inline

The error occurred while setting parameters

SQL: update student_point_level s set s.score = ? where s.id = ? ; update student_point_level s set s.score = ? where s.id = ?

Cause: com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: 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 student_point_level s

        set s.score = 16
        where s.id = 19' at line 7

; bad SQL grammar []; nested exception is com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: 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 student_point_level s
set s.score = 16
where s.id = 19' at line 7

展开
收起
爱吃鱼的程序员 2020-06-23 14:00:54 709 0
1 条回答
写回答
取消 提交回答
  • https://developer.aliyun.com/profile/5yerqm5bn5yqg?spm=a2c6h.12873639.0.0.6eae304abcjaIB

    经过朋友的帮助,此问题已经解决。
    参考:http://www.cnblogs.com/hyq0002013/p/6077847.html

    把你的xml里面的sql全部贴上来看看

    <?xmlversion="1.0"encoding="UTF-8"?>
    <!DOCTYPEmapperPUBLIC"-//mybatis.org//DTDMapper3.0//EN""http://mybatis.org/dtd/mybatis-3-mapper.dtd">







    <updateid="updateStudentPointLevelBatch"parameterType="java.util.List"><foreachcollection="list"item="item"index="index"open=""close=";"separator=";">updatestudent_point_levelssets.score=#{item.score}wheres.id=#{item.id}</foreach></update><insertid="insertStudentPointLevelBatch">insertintoSTUDENT_POINT_LEVEL(POINT_ID,STUDENT_ID,SCORE,DATETIME)values<foreachcollection="list"item="item"index="index"separator=",">(#{item.pointId},#{item.studentId},#{item.score},now())</foreach></insert>

    2020-06-23 14:01:11
    赞同 展开评论 打赏
问答排行榜
最热
最新

相关电子书

更多
Java Spring Boot开发实战系列课程【第6讲】:Spring Boot 2.0实战MyBatis与优化(Java面试题) 立即下载
低代码开发师(初级)实战教程 立即下载
阿里巴巴DevOps 最佳实践手册 立即下载