Java利用pageHelper分页查询大数据量

分页获取10000条数据

        int currentPage = 1;
        int pageSize = 1000;
        int total = 10;
        List<TScmVatNotDeduct> data = new ArrayList<TScmVatNotDeduct>();
        // results 最终的查询结果
        List<TScmVatNotDeduct> results = new ArrayList<TScmVatNotDeduct>();    
        while (total>0) {
        	data = null;
            Page<TScmVatNotDeduct> page = PageHelper.startPage(currentPage, pageSize);
			List<TScmVatNotDeduct> confirmNotDeductList = notDeductMapper.confirmNotDeductList(request);
			data = page.getResult();
			if (data.size() < pageSize) {
				data = page.getResult();
				results.addAll(data);
				total = -1;
				break;
			}
			results.addAll(data);
			currentPage++;
			total--;
        }
发布了68 篇原创文章 · 获赞 5 · 访问量 9805

猜你喜欢

转载自blog.csdn.net/weixin_44407691/article/details/103537951