我正在尝试更新多个数据库行.使用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>
给出错误:
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 employee_trips set pickup_drop_time = ’01:35:00′ where id = 10’ at line 3
最佳答案 将参数allowMultiQueries = true附加到JDBC的URL,然后尝试:
mapper.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>
Mapper.java
updateEmployeeTrips(List<employeeTrip> employeeTripList)