Skip to content

Commit

Permalink
fix update batch
Browse files Browse the repository at this point in the history
  • Loading branch information
timyuer committed Aug 28, 2024
1 parent a6ac143 commit 86e4456
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 19 deletions.
19 changes: 10 additions & 9 deletions bigtop-manager-dao/src/main/resources/mapper/mysql/StageMapper.xml
Original file line number Diff line number Diff line change
Expand Up @@ -23,15 +23,16 @@
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="org.apache.bigtop.manager.dao.mapper.StageMapper">

<update id="updateStateByIds">
<foreach collection='stages' item='stage' separator=';'>
update stage
<set>
<if test="stage.state != null and stage.state != ''">
`state` = #{stage.state},
</if>
</set>
where id = #{stage.id}
<update id="updateStateByIds" parameterType="java.util.List">
UPDATE stage
SET `state` = CASE
<foreach collection="stages" item="item" index="index">
WHEN id = #{item.id} THEN #{item.state}
</foreach>
END
WHERE id IN
<foreach collection="stages" index="index" item="item" open="(" separator="," close=")">
#{item.id}
</foreach>
</update>

Expand Down
19 changes: 10 additions & 9 deletions bigtop-manager-dao/src/main/resources/mapper/mysql/TaskMapper.xml
Original file line number Diff line number Diff line change
Expand Up @@ -23,15 +23,16 @@
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="org.apache.bigtop.manager.dao.mapper.TaskMapper">

<update id="updateStateByIds">
<foreach collection='tasks' item='task' separator=';'>
update task
<set>
<if test="task.state != null and task.state != ''">
`state` = #{task.state},
</if>
</set>
where id = #{task.id}
<update id="updateStateByIds" parameterType="java.util.List">
UPDATE task
SET `state` = CASE
<foreach collection="tasks" item="item" index="index">
WHEN id = #{item.id} THEN #{item.state}
</foreach>
END
WHERE id IN
<foreach collection="tasks" index="index" item="item" open="(" separator="," close=")">
#{item.id}
</foreach>
</update>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@

<logger name="eclipselink.logging" level="DEBUG" additivity="true" />

<root level="INFO">
<root level="DEBUG">
<appender-ref ref="STDOUT" />
<appender-ref ref="SERVER_LOG_FILE" />
</root>
Expand Down

0 comments on commit 86e4456

Please sign in to comment.