我正在尝试更新多个数据库行。使用 mybatis 3.1spring 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>

给出错误:

最佳答案

将参数 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)

关于spring-mvc - Spring中更新多个数据库行-Mybatis,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/35480461/

10-10 18:08