zoukankan      html  css  js  c++  java
  • Java 一次操作多条数据

    //新增
    <insert id="insertSelectiveList"  useGeneratedKeys="true" parameterType="java.util.List">
        insert into common_user (user_id, user_account, user_name,
        password, nick_name, avatar,
        salt, mobile, tel,
        email, status, isdel, create_time,
        last_mod_time, create_user_id, mod_user_id,
        open_id, region_code, region_name
        )
        values
        <foreach collection="list" item="item" index="index" separator="," close=";">
          (#{item.userId,jdbcType=BIGINT}, #{item.userAccount,jdbcType=VARCHAR}, #{item.userName,jdbcType=VARCHAR},
          #{item.password,jdbcType=VARCHAR}, #{item.nickName,jdbcType=VARCHAR}, #{item.avatar,jdbcType=VARCHAR},
          #{item.salt,jdbcType=VARCHAR}, #{item.mobile,jdbcType=VARCHAR}, #{item.tel,jdbcType=VARCHAR},
          #{item.email,jdbcType=VARCHAR}, #{item.status,jdbcType=CHAR}, #{item.isdel,jdbcType=CHAR}, #{item.createTime,jdbcType=TIMESTAMP},
          #{item.lastModTime,jdbcType=TIMESTAMP}, #{item.createUserId,jdbcType=BIGINT}, #{item.modUserId,jdbcType=BIGINT},
          #{item.openId,jdbcType=VARCHAR}, #{item.regionCode,jdbcType=VARCHAR}, #{item.regionName,jdbcType=VARCHAR}
          )
        </foreach>
      </insert>
    //删除
      <delete id="deluserByaccount" parameterType="java.util.ArrayList" >
        delete from common_user
        <where>
            user_account in (
            <foreach collection="list"  item="code" index="index" separator=",">
                #{code}
            </foreach>
            )
        </where>
    </delete>
    //更新
    <update id="updateMemberList" parameterType="java.util.List" >
    <foreach collection="list" item="item" index="index" open="" close="" separator=";">
    update common_party_member
    <set >
    <if test="name != null" >
    name = #{item.name,jdbcType=VARCHAR},
    </if>
    <if test="sex != null" >
    sex = #{item.sex,jdbcType=VARCHAR},
    </if>
    <if test="provinceCode != null" >
    province_code = #{item.provinceCode,jdbcType=VARCHAR},
    </if>
    <if test="cityCode != null" >
    city_code = #{item.cityCode,jdbcType=VARCHAR},
    </if>
    <if test="areaCode != null" >
    area_code = #{item.areaCode,jdbcType=VARCHAR},
    </if>

    <if test="salt != null" >
    salt = #{item.salt,jdbcType=VARCHAR},
    </if>
    <if test="idNumber != null" >
    id_number = #{item.idNumber,jdbcType=VARCHAR},
    </if>
    <if test="education != null" >
    education = #{item.education,jdbcType=VARCHAR},
    </if>

    <if test="address != null" >
    address = #{item.address,jdbcType=VARCHAR},
    </if>
    <if test="mobile != null" >
    mobile = #{item.mobile,jdbcType=VARCHAR},
    </if>
    <if test="company != null" >
    company = #{item.company,jdbcType=VARCHAR},
    </if>

    <if test="jobTitle != null" >
    job_title = #{item.jobTitle,jdbcType=VARCHAR},
    </if>

    <if test="birthday != null" >
    birthday = #{item.birthday,jdbcType=TIMESTAMP},
    </if>

    <if test="memberProperties != null" >
    member_properties = #{item.memberProperties,jdbcType=TINYINT},
    </if>

    <if test="innerPartyPositon != null" >
    inner_party_positon = #{item.innerPartyPositon,jdbcType=VARCHAR},
    </if>

    <if test="partyTime != null" >
    party_time = #{item.partyTime,jdbcType=VARCHAR},
    </if>
    <if test="partyOrganId != null" >
    party_organ_id = #{item.partyOrganId,jdbcType=BIGINT},
    </if>
    <if test="isPartyAdmin != null" >
    is_party_admin = #{item.isPartyAdmin,jdbcType=CHAR},
    </if>
    <if test="isMemberOnline != null" >
    is_member_online = #{item.isMemberOnline,jdbcType=CHAR},
    </if>
    <if test="isPartyOrganActivity != null" >
    is_party_organ_activity = #{item.isPartyOrganActivity,jdbcType=CHAR},
    </if>
    <if test="isMassOrganization != null" >
    is_mass_organization = #{item.isMassOrganization,jdbcType=CHAR},
    </if>

    <if test="remark != null" >
    remark = #{item.remark,jdbcType=VARCHAR},
    </if>

    <if test="modUserId != null" >
    mod_user_id = #{item.modUserId,jdbcType=BIGINT},
    </if>
    <if test="lastModTime != null" >
    last_mod_time = #{item.lastModTime,jdbcType=TIMESTAMP},
    </if>

    </set>
    where id = #{item.id,jdbcType=BIGINT}
    </foreach>
    </update>
  • 相关阅读:
    select poll使用
    linux下tomcat shutdown后 java进程依然存在
    poj 1222 EXTENDED LIGHTS OUT(高斯消元)
    poj 2377 Bad Cowtractors
    C#:总结页面传值几种方法
    从 Racket 入门函数式编程
    程序猿接私活经验总结,来自csdn论坛语录
    什么是SEO?SEO干嘛的?怎么做SEO?
    Java设计模式-观察者模式
    非常特别的一个动态规划新手教程
  • 原文地址:https://www.cnblogs.com/yyjspace/p/14807325.html
Copyright © 2011-2022 走看看