[mybatis] 다중 업데이트 – 리스트

리스트를 이용한 업데이트

자바단에서 리스트 루프가 아닌 마이바티스에서 루프 돌리는 방법

참고: https://stackoverflow.com/questions/35480461/updating-multiple-database-rows-in-spring-mybatis

선행: JDBC 커넥션 스트링에 다음을 추가.
allowMultiQueries=true

<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>
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

w

Connecting to %s