数据库:PostgreSQL,MYSQL
@Mapper
public interface CheckQualificationInfoMapper {
// 方法一
@Insert({""})
void batchSaveInfo(@Param("poList") List poList);
//方法二:
@InsertProvider(type = BatchSaveCheckDTO.class,method = "insertAll" )
public void insertAll(@Param("poList") List poList);
public class BatchSaveCheckDTO {
public String insertAll(@Param("poList") List poList) {
StringBuilder sb = new StringBuilder();
sb.append("INSERT INTO check_qualification_info ");
sb.append("( name, id_no, mobile,apply_no ,cust_no ,batch_id, reason) ");
sb.append("VALUES ");
MessageFormat mf = new MessageFormat("(#'{'poList[{0}].name},#'{'poList[{0}].idNo},#'{'poList[{0}].phone},#'{'poList[{0}].applyNo}" +
",#'{'poList[{0}].custNo},#'{'poList[{0}].batchId},#'{'poList[{0}].reason})");
for (int i = 0; i < poList.size(); i++) {
sb.append(mf.format(new Object[]{i}));
if (i < poList.size() - 1) {
sb.append(",");
}
}
return sb.toString();
}
}
//方法三:
@Insert("")
boolean bathInsertStatitisticsInfo(@Param("infoList") List infoList);
}
public class CheckQualificationInfoPO {
private String id;
private String name;
private String phone;
private String idNo;
private String applyNo;
private String reason;
private String custNo;
private String batchId;
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getPhone() {
return phone;
}
public void setPhone(String phone) {
this.phone = phone;
}
public String getIdNo() {
return idNo;
}
public void setIdNo(String idNo) {
this.idNo = idNo;
}
public String getApplyNo() {
return applyNo;
}
public void setApplyNo(String applyNo) {
this.applyNo = applyNo;
}
public String getReason() {
return reason;
}
public void setReason(String reason) {
this.reason = reason;
}
public String getCustNo() {
return custNo;
}
public void setCustNo(String custNo) {
this.custNo = custNo;
}
public String getBatchId() {
return batchId;
}
public void setBatchId(String batchId) {
this.batchId = batchId;
}
@Override
public String toString() {
return "CheckQualificationInfoPO{" +
"id='" + id + '\'' +
", name='" + name + '\'' +
", phone='" + phone + '\'' +
", idNo='" + idNo + '\'' +
", applyNo='" + applyNo + '\'' +
", reason='" + reason + '\'' +
", custNo='" + custNo + '\'' +
", batchId='" + batchId + '\'' +
'}';
}
}
数据库:Oracle
import org.apache.ibatis.annotations.*;
import java.text.MessageFormat;
import java.util.List;
import java.util.Map;
@Mapper
public interface ContactsMapper {
/***
* @Description: 方法一;loanType和 applyNo为每条数据的公共参数
* @Date: 2019-10-16
*/
@Insert("")
public void insertTelList(@Param("map") Map map);
/**
* @Description: 方法二;loanType和 applyNo为每条数据的公共参数;设置到每个Map里面(比较死板,不如方法三)
* @Date: 2019-10-16
*/
@InsertProvider(type = InsertContactsAll.class , method = "insertContactsAll")
int inserAll(@Param("contactList") List