如果要在一个update里面执行多条更新语句,只需要在jdbc:url后面跟上allowMultiQueries=true的参数,比如:
spring.datasource.url=jdbc:mysql://localhost:3306/wang_last?allowMultiQueries=true
不加这一句,即使mybatis里面的查询语句没有问题,也会报错:
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
viscosity_fitting set
viscosity_id = 2,
’ at line 12
下面附上xml里面的代码
<update id="updateViscosityFittings" parameterType="com.cup.wang.airport.model.ViscosityFitting" useGeneratedKeys="true" keyProperty="id">