UPDATE hs_config
SET value = CASE name
WHEN 'agreement' THEN 322222
WHEN 'aboutus' THEN 2222
END |
UPDATE hs_config
SET value = CASE name
WHEN 'agreement' THEN 322222
WHEN 'aboutus' THEN 2222
END
Integer updateConfigByNameBatch(@Param("map") Map<String,Object> map); |
Integer updateConfigByNameBatch(@Param("map") Map<String,Object> map);
<update id="updateConfigByNameBatch">
UPDATE hs_config SET value = CASE name
<foreach collection="map.keys" item="key" index="index">
WHEN #{key} THEN #{map[${key}]}
</foreach>
END
</update> |
<update id="updateConfigByNameBatch">
UPDATE hs_config SET value = CASE name
<foreach collection="map.keys" item="key" index="index">
WHEN #{key} THEN #{map[${key}]}
</foreach>
END
</update>
默认,如果数据表中的其他记录匹配不到值,会报这个错:java.sql.SQLIntegrityConstraintViolationException: Column ‘value’ cannot be null