第一种方法:使用mybatis的Service CRUD接口 saveBatch()
saveBatch
/**
* 插入(批量)
*
* @param entityList 实体对象集合
* @param batchSize 插入批次数量
*/
boolean saveBatch(Collection<T> entityList);
#saveBatch
/**
* 插入(批量)
*
* @param entityList 实体对象集合
* @param batchSize 插入批次数量
*/
boolean saveBatch(Collection<T> entityList, int batchSize);
实现层代码:
@Override
public Result roleRelationRoot(int roleId, List<Integer> rootIds) {
List list = new ArrayList();
for(int i=0;i<rootIds.size(