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>
Java 一次操作多条数据的更多相关文章
- 使用JWPL (Java Wikipedia Library)操作维基百科数据
使用JWPL (Java Wikipedia Library)操作维基百科数据 1. JWPL介绍 JWPL(Java Wikipedia Library)是一个开源的访问wikipeida数据的Ja ...
- Java备份约9亿条数据
需求:有一张表9亿多条数据,数据加索引总数据量61GB.考虑到这张表的大部分数据都不会再被使用并且大数据量可能影响整库的性能,所以决定将表里某一个时刻之前的数据备份到一张新表中,待备份完成后将旧表中已 ...
- java向数据库插入N条数据
为了测试mysql的索引,要向数据库先插入上万条数据,然后再测试.手动插入太麻烦,写了一段代码. 先上代码: package action; import java.sql.Connection; i ...
- java 对excel操作导入excel数据到数据库
加入jar包jxl.jar ===================services层掉用工具类==================================== // 导入 public Lis ...
- java 批量插入10万条数据
for (int i = 0; i < 100000; i++) { dbHelper.insert("INSERT aaa(name) Values ('1')"); } ...
- java操作mongodb——更新数据
Java中可以通过updateOne,updateMany,replaceOne方法进行集合的文档更新.但是 _id 是不能更新的 updateOne只会更新一条数据,即使通过Filters.lt(& ...
- SQL语言(二) java怎样连接操作数据库中的数据
import java.sql.Connection;import java.sql.DriverManager;import java.sql.ResultSet;import java.sql.S ...
- easyUI dialog打开对话框,显示列表数据,选取一条数据操作后赋值给父窗口 resultMap声明为全局,生成getset方法
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8" ...
- Java 线程池 +生产者消费者+MySQL读取300 万条数据
1.1需求 数据库300 万条用户数据 ,遍历获取所有用户, 各种组合关联, 获取到一个新的json ,存到redis 上. 1.2 难点 数据库比较多, 不可能单线程查询所有的数据到内存. 1.3解 ...
- Java操作Jxl实现数据交互。三部曲——《第三篇》
Java操作Jxl实现上传文本文件实现转PDF格式在线预览. 本文实现背景Web项目:前台用的框架是Easyui+Bootstrap结合使用,需要引入相应的Js.Css文件.页面:Jsp.拦截请求:S ...
随机推荐
- 《Toward Fast, Flexible, and Robust Low-Light Image Enhancement》
1.(23条消息) 图像增强评价标准EME和matlab代码_eme指标_zhonglingyuxiuYYX的博客-CSDN博客 2.nn.moduleList 3.LOE:lightness ord ...
- linux批量操作(一)
一.常用命令 1.关闭所有java进程命令: ps -ef | grep java | grep -v grep | awk '{print $2}' | xargs kill -9 2.批量文本操作 ...
- GitLab-Runner安装及使用
Git_Lab CI Setting 根据该教程本地下载并安装 gitlab-runner.exe 在GitLab远程仓库页面点击 setting-> CI/CD ->runner Exp ...
- Codeforces Round #827 (Div. 4) 复盘+题解
原比赛链接 复盘: ABC签到,手速太慢了. D捣鼓了好久才想起来从更小的值域出发去做. E简单二分答案. 然后就time out了.D题搞错方向浪费太久时间了. F思维题,考虑到初值.字符集,然后是 ...
- Delphi获取程序版本号
参考: http://www.delphitop.com/html/hanshu/4627.html procedure GetVersionInfo(const FileName:string; v ...
- react native 音频播放 react-native-sound
先放一个效果图:该图实现的效果,点击播放按钮,进度条随着时间移动,点击暂停按钮,进度条停止移动 第一步,用到什么库 1.zmxv/react-native-sound 播放声音的库 2.calls ...
- Linux df -h 显示磁盘空间满,但实际未占用满——问题分析
问题现象: 遇到一个问题,在系统上,告警提示磁盘空间不够,如下图所示: 问题分析: 1.首先使用 :du -h / --max-depth=1 命令查看各个目录的占用空间,试图找到占用较多空间的目 ...
- js格式转化
js对象转json数据(json字符串): let obj = {'name': '张三','age': 18} let data = JSON.stringify(obj); conlose.log ...
- Java基础__06.注解和反射
注解 什么是注解? 1.注解:annocation,是从JDK5.0开始引进入的新技术. 2.注解的作用: 不是程序本身,可以对程序做出解释,这一点和注释一样: 可以被其他程序读取,这点是和注释的区别 ...
- Java基础__02.数据类型
Java中的数据类型 Java是一种强类型的语言,所有的变量都必须要先定义才能使用. Java中的数据类型分为 基本数据类型和引用数据类型. 1.基本数据类型:(8种) 数值类型 整数类型 byte: ...