本文整理汇总了Java中org.springframework.data.domain.Page.nextPageable方法的典型用法代码示例。如果您正苦于以下问题:Java Page.nextPageable方法的具体用法?Java Page.nextPageable怎么用?Java Page.nextPageable使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.springframework.data.domain.Page
的用法示例。
在下文中一共展示了Page.nextPageable方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: doSubjectMigration
import org.springframework.data.domain.Page; //导入方法依赖的package包/类
public void doSubjectMigration(final SubjectRepository subjectRepository,
final GraphSubjectRepository subjectHierarchicalRepository, final int pageSize) {
int numOfSubjectsSaved = 0;
Pageable pageRequest = new PageRequest(0, pageSize, new Sort("id"));
long numOfSubjectEntitiesToMigrate = subjectRepository.count();
Page<SubjectEntity> pageOfSubjects;
do {
pageOfSubjects = subjectRepository.findAll(pageRequest);
List<SubjectEntity> subjectListToSave = pageOfSubjects.getContent();
numOfSubjectsSaved += pageOfSubjects.getNumberOfElements();
subjectListToSave.forEach(item -> {
item.setId(0);
LOGGER.trace("doSubjectMigration Subject-Id: {} Zone-name: {} Zone-id: {}", item.getSubjectIdentifier(),
item.getZone().getName(), item.getZone().getId());
});
subjectHierarchicalRepository.save(subjectListToSave);
LOGGER.info("Total subjects migrated so far: {}/{}", numOfSubjectsSaved, numOfSubjectEntitiesToMigrate);
pageRequest = pageOfSubjects.nextPageable();
} while (pageOfSubjects.hasNext());
LOGGER.info("Number of subject entities migrated: {}", numOfSubjectsSaved);
LOGGER.info("Subject migration to Titan completed.");
}
示例2: doResourceMigration
import org.springframework.data.domain.Page; //导入方法依赖的package包/类
public void doResourceMigration(final ResourceRepository resourceRepository,
final GraphResourceRepository resourceHierarchicalRepository, final int pageSize) {
int numOfResourcesSaved = 0;
Pageable pageRequest = new PageRequest(0, pageSize, new Sort("id"));
long numOfResourceEntitiesToMigrate = resourceRepository.count();
Page<ResourceEntity> pageOfResources;
do {
pageOfResources = resourceRepository.findAll(pageRequest);
List<ResourceEntity> resourceListToSave = pageOfResources.getContent();
numOfResourcesSaved += pageOfResources.getNumberOfElements();
resourceListToSave.forEach(item -> {
// Clear the auto-generated id field prior to migrating to graphDB
item.setId((long) 0);
LOGGER.trace("doResourceMigration Resource-Id: {} Zone-name: {} Zone-id: {}",
item.getResourceIdentifier(), item.getZone().getName(), item.getZone().getId());
});
resourceHierarchicalRepository.save(resourceListToSave);
LOGGER.info("Total resources migrated so far: {}/{}", numOfResourcesSaved, numOfResourceEntitiesToMigrate);
pageRequest = pageOfResources.nextPageable();
} while (pageOfResources.hasNext());
LOGGER.info("Number of resource entities migrated: {}", numOfResourcesSaved);
LOGGER.info("Resource migration to Titan completed.");
}
示例3: findAll
import org.springframework.data.domain.Page; //导入方法依赖的package包/类
@Override
public Page<ProbeVo> findAll(int page, int size) {
Page<ProbeEntity> probeEntities = probeDao.findAll(page, size);
return new PageImpl<>(probeEntities.getContent().stream().map(ProbeVo::new).collect(Collectors.toList()),
probeEntities.nextPageable(),probeEntities.getTotalElements());
}