template might not exist or might not be accessible by any of the configured Template Resolvers
这是我的代码
<update id="deleteDevice">
delete from p_human
where id in(
<foreach collection="idList" item="id" separator=",">
#{id}
</foreach>
)
</update>
当我进行少量删除的时候并没有问题,但是删除一千多条数据的时候,它它它竟然报错了,我便开始搜搜搜(因为我并不想在业务层循环)
然后找到了各种介绍,有引用pom的,此处省略,最终我用了这种方法
public void deleteDevice(String idS,String userId) {
//这里我转了一下数组
Long [] id= Convert.toLongArray(idS);
//能力有限,我又转了一下
List<Long> idList = Arrays.asList(id);
if(idList != null && idList.size()>0){
Integer count =idList.size();
Integer queryNumOne = count / 100;//循环次数,一次100条
if (count % 100 != 0) {//有余数循环次数+1
queryNumOne++;
}
Integer num = 0;
for (int index = 0; index < queryNumOne; index++) {
Integer num1 = 100;
if(queryNumOne==index+1){
num1=count % 100;
}
List<Long> param = idList.subList(num, num + num1);
num = num + 100;
//开始搞起来
mainImMapper.deleteDevice(param,userId);
}
}
}