@RequestMapping(value = "/todos2.csv", method = RequestMethod.GET) public void exportTodosCSVSlicing(HttpServletResponse response) { final int PAGE_SIZE = 1000; response.addHeader("Content-Type", "application/csv"); response.addHeader("Content-Disposition", "attachment; filename=todos.csv"); response.setCharacterEncoding("UTF-8"); try { PrintWriter out = response.getWriter(); int page = 0; Slice<Todo> todoPage; do { todoPage = todoRepository.findAllBy(new PageRequest(page, PAGE_SIZE)); for (Todo todo : todoPage) { String line = todoToCSV(todo); out.write(line); out.write("\n"); } entityManager.clear(); page++; } while (todoPage.hasNext()); out.flush(); } catch (IOException e) { log.info("Exception occurred " + e.getMessage(), e); throw new RuntimeException("Exception occurred while exporting results", e); } }
} while (idProjections.hasNext() && totalAttemptedDeletions < maxDeleted);
return; if (needsToWarn.hasNext()) { Pageable pageable = needsToWarn.nextPageable(); needsToWarn = needRepository.findNeedsInactiveBetweenAndNotConnected(startWarningThreshold, stopWarningThreshold, pageable); return; if (needsToDeactivate.hasNext()) { Pageable pageable = needsToDeactivate.nextPageable(); needsToDeactivate = needRepository.findNeedsInactiveSinceAndNotConnected(deactivateThreshold, pageable); return; if (needsToDeactivate.hasNext()) { Pageable pageable = needsToDeactivate.nextPageable(); needsToDeactivate = needRepository.findNeedsInactiveSince(deactivateThresholdDespiteEstablishedConnections, pageable);