网站的访问量怎么查,html5开发的网站,西宁知名网站制作公司,中国建设银行网上银行官网在实际生产开发中,我们都知道,DB是影响响应速度的主要原因之一,因此都会选择尽可能减少操作DB的次数,所以在批量操作数据库时,都会选择一些方式去尽可能优化。
一、实体类和mapper
实体类为:
@Data
public class User {private Long userId;private String name;priva…在实际生产开发中,我们都知道,DB是影响响应速度的主要原因之一,因此都会选择尽可能减少操作DB的次数,所以在批量操作数据库时,都会选择一些方式去尽可能优化。
一、实体类和mapper
实体类为:
@Data
public class User {private Long userId;private String name;private String gender;private Date createTime;}
UserMapper中的方法声明:
// 批量插入
int batchInsertUser(ListUser users);// 批量更新
int batchUpdateUser(ListUser users);
二、批量插入xml
批量插入对应的xml中SQL语句的拼接如下:
insert id="batchInsertUser" parameterType="java.util.List"insert into tb_user (user_id, name, gender, create_time) valuesforeach collection="users" item="user" separator=","(if test="user.userId != null and user.userId != 0"#