Java 一次操作多条数据
2024-10-21 18:39:08
//新增
<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>
最新文章
- java多线程系列之 synchronized
- SpringMVC国际化
- WCF初探-6:WCF服务配置
- [Weekly] 2014.03.01-2014.03.08
- 用过的一个jquery插件实现转盘效果还不错手机兼容
- HDU-4614 Vases and Flowers (线段树区间更新)
- VIM编辑器常用功能整理笔记
- MBR
- ionic开发环境搭建
- Git命令非主流札记
- PAT (Advanced Level) 1081. Rational Sum (20)
- COM组件转换为.NET元数据2
- better-scroll不能滚动之 滚动监听-左右联动
- nosql:文件存储和sql数据库存储形式之外的存储系统都是nosql
- Jquery遍历之获取子级元素、同级元素和父级元素
- C#如何Json转字符串;字符串转Json;Newtonsoft.Json(Json.Net)
- jquery基础学习之事件篇(三)
- Dom操作的常用案例实现
- 构建微服务:快速搭建Spring Boot项目
- error MSB3552: Resource file ";**/*.resx"; cannot be found. [/ConsoleApp1.csproj]