4

我正在尝试更新多个数据库行。使用mybatis 3.1这里spring 3 是我的更新查询mapper.xml

<update id="updateEmployeeTrips" parameterType="com.xxx.xxx.EmployeeTrip">
    <foreach collection="list" item="employeeTrips" index="index" separator=";">
        update employee_trips set pickup_drop_time = #{employeeTrips.pickupTime} where id = #{employeeTrips.id}
    </foreach>
</update>

给出错误:

您的 SQL 语法有错误;检查与您的 MySQL 服务器版本相对应的手册,以在第 3 行的 'update employee_trips set Pickup_drop_time = '01:35:00' where id = 10' 附近使用正确的语法

4

1 回答 1

5

将参数附加allowMultiQueries=true到 JDBC 的 URL,然后尝试以下操作:

映射器.xml:

<update id="updateEmployeeTrips" parameterType="java.util.List">
    <foreach collection="list" item="employeeTrips" index="index" separator=";">
        update employee_trips set pickup_drop_time = #{employeeTrips.pickupTime} where id = #{employeeTrips.id}
    </foreach>
</update>

映射器.java

updateEmployeeTrips(List<employeeTrip> employeeTripList)
于 2016-02-19T12:48:17.927 回答