批量操作list对象
程序员文章站
2022-07-04 17:05:10
...
<insert id="insertForeach" parameterType="java.util.List"> insert into mb_member_devinfo (id, member_id, name, phone, org_id, org_name, stage, state, sort, createtime, tenant_code) values <foreach collection="list" item="item" index="index" separator="," > (#{item.id,jdbcType=VARCHAR}, #{item.memberId,jdbcType=VARCHAR}, # {item.name,jdbcType=VARCHAR}, #{item.phone,jdbcType=VARCHAR}, #{item.orgId,jdbcType=VARCHAR}, # {item.orgName,jdbcType=VARCHAR}, #{item.stage,jdbcType=VARCHAR},#{item.state,jdbcType=VARCHAR}, # {item.sort,jdbcType=VARCHAR}, #{item.createtime,jdbcType=BIGINT}, # {item.tenantCode,jdbcType=VARCHAR}) </foreach> </insert>
<update id="updateForeach" parameterType="java.util.List"> update mb_member_login <trim prefix="set" suffixOverrides=","> <trim prefix="password = case" suffix="end,"> <foreach collection="list" item="item" index="index"> when member_id=#{item.memberId} then # {item.password} </foreach> </trim> </trim> where member_id in <foreach collection="list" index="index" item="item" separator="," open="(" close=")"> #{item.memberId,jdbcType=BIGINT} </foreach> and state='1' </update>
上一篇: 不打扰它们休息了
下一篇: IT程序员喝酒喝出的计算机文化!