/**1k一批直接插入到数据库*/ private static final int OPENID_PHONE_NUM = 1000; @Override public long saveValidateList(List<AreasTargetHospitalValidate> validateList) { int listSize=validateList.size(); int toIndex=OPENID_PHONE_NUM; int count=0; for(int i = 0;i<validateList.size();i+=OPENID_PHONE_NUM){ if(i+OPENID_PHONE_NUM>listSize){ //作用为toIndex最后没有800条数据则剩余几条newList中就装几条 toIndex=listSize-i; } List<AreasTargetHospitalValidate> newValidateList = validateList.subList(i,i+toIndex); //批量插入 baseMapper.saveValidateList(newValidateList); count=count+OPENID_PHONE_NUM; } return count; }
解决大批量数据入库时造成的IO异常
最新推荐文章于 2022-06-21 15:50:03 发布