Codota Logo
PageRequest.<init>
Code IndexAdd Codota to your IDE (free)

How to use
org.springframework.data.domain.PageRequest
constructor

Best Java code snippets using org.springframework.data.domain.PageRequest.<init> (Showing top 20 results out of 1,206)

  • Common ways to obtain PageRequest
private void myMethod () {
PageRequest p =
  • Codota Iconnew PageRequest(page, size)
  • Codota IconSort sort;new PageRequest(page, size, sort)
  • Codota IconPageRequest.of(page, size)
  • Smart code suggestions by Codota
}
origin: stackoverflow.com

 Pageable topTen = new PageRequest(0, 10);
Page<User> result = repository.findByUsername("Matthews", topTen);
Assert.assertThat(result.isFirstPage(), is(true));
origin: stackoverflow.com

 Pageable topTen = new PageRequest(0, 10);
List<User> result = repository.findByUsername("Matthews", topTen);
origin: stackoverflow.com

 // Keep that in a constant if it stays the same
PageRequest request = new PageRequest(0, 1, new Sort(Sort.Direction.DESC, "created"));
Job job = repository.findOneActiveOldest(request).getContent().get(0);
origin: macrozheng/mall

@Override
public Page<EsProduct> search(String keyword, Integer pageNum, Integer pageSize) {
  Pageable pageable = new PageRequest(pageNum, pageSize);
  return productRepository.findByNameOrSubTitleOrKeywords(keyword, keyword, keyword, pageable);
}
origin: Raysmond/SpringBlog

public Page<Post> getAllPublishedPostsByPage(int page, int pageSize) {
  log.debug("Get posts by page " + page);
  return postRepository.findAllByPostTypeAndPostStatus(
      PostType.POST,
      PostStatus.PUBLISHED,
      new PageRequest(page, pageSize, Sort.Direction.DESC, "createdAt"));
}
origin: Raysmond/SpringBlog

public Page<Post> findPostsByTag(String tagName, int page, int pageSize) {
  return postRepository.findByTag(tagName, new PageRequest(page, pageSize, Sort.Direction.DESC, "createdAt"));
}
origin: Raysmond/SpringBlog

@GetMapping("")
public String index(@RequestParam(defaultValue = "0") int page, Model model) {
  Page<Post> posts = postRepository.findAll(new PageRequest(page, PAGE_SIZE, Sort.Direction.DESC, "id"));
  model.addAttribute("totalPages", posts.getTotalPages());
  model.addAttribute("page", page);
  model.addAttribute("posts", posts);
  return "admin/posts/index";
}
origin: Raysmond/SpringBlog

public List<Post> getArchivePosts() {
  log.debug("Get all archive posts from database.");
  Pageable page = new PageRequest(0, Integer.MAX_VALUE, Sort.Direction.DESC, "createdAt");
  return postRepository.findAllByPostTypeAndPostStatus(PostType.POST, PostStatus.PUBLISHED, page)
      .getContent()
      .stream()
      .map(this::extractPostMeta)
      .collect(Collectors.toList());
}
origin: 527515025/springBoot

  @RequestMapping(value = "/save", method = RequestMethod.POST)
  public List<Person> savePerson(@RequestBody String personName) {
    Person p = new Person(personName);
    personRepository.save(p);
    List<Person> people = personRepository.findAll(new PageRequest(0, 10)).getContent();
    return people;
  }
}
origin: stackoverflow.com

final int pageLimit = 300;
   int pageNumber = 0;
   Page<T> page = repository.findAll(new PageRequest(pageNumber, pageLimit));
   while (page.hasNextPage()) {
     processPageContent(page.getContent());
     page = repository.findAll(new PageRequest(++pageNumber, pageLimit));
   }
   // process last page
   processPageContent(page.getContent());
origin: macrozheng/mall

@Override
public Page<EsProduct> recommend(Long id, Integer pageNum, Integer pageSize) {
  Pageable pageable = new PageRequest(pageNum, pageSize);
  List<EsProduct> esProductList = productDao.getAllEsProductList(id);
  if (esProductList.size() > 0) {
    EsProduct esProduct = esProductList.get(0);
    String keyword = esProduct.getName();
    Long brandId = esProduct.getBrandId();
    Long productCategoryId = esProduct.getProductCategoryId();
    //根据商品标题、品牌、分类进行搜索
    FunctionScoreQueryBuilder functionScoreQueryBuilder = QueryBuilders.functionScoreQuery()
        .add(QueryBuilders.matchQuery("name",keyword),ScoreFunctionBuilders.weightFactorFunction(8))
        .add(QueryBuilders.matchQuery("subTitle",keyword),ScoreFunctionBuilders.weightFactorFunction(2))
        .add(QueryBuilders.matchQuery("keywords",keyword),ScoreFunctionBuilders.weightFactorFunction(2))
        .add(QueryBuilders.termQuery("brandId",brandId),ScoreFunctionBuilders.weightFactorFunction(10))
        .add(QueryBuilders.matchQuery("productCategoryId",productCategoryId),ScoreFunctionBuilders.weightFactorFunction(6))
        .scoreMode("sum")
        .setMinScore(2);
    NativeSearchQueryBuilder builder = new NativeSearchQueryBuilder();
    builder.withQuery(functionScoreQueryBuilder);
    builder.withPageable(pageable);
    NativeSearchQuery searchQuery = builder.build();
    LOGGER.info("DSL:{}", searchQuery.getQuery().toString());
    return productRepository.search(searchQuery);
  }
  return new PageImpl<>(null);
}
origin: apache/servicecomb-pack

 public void clearCompletedGlobalTx(int size) {
  tccTxEventRepository.clearCompletedGlobalTx(new PageRequest(0, size));
 }
}
origin: armzilla/amazon-echo-ha-bridge

@RequestMapping(value = "/{userId}/lights", method = RequestMethod.GET, produces = "application/json")
public ResponseEntity<Map<String, String>> getUpnpConfiguration(@PathVariable(value = "userId") String userId, HttpServletRequest request) {
  log.info("hue lights list requested: " + userId + " from " + request.getRemoteAddr() + request.getLocalPort());
  int pageNumber = request.getLocalPort()-portBase;
  Page<DeviceDescriptor> deviceList = repository.findByDeviceType("switch", new PageRequest(pageNumber, 25));
  Map<String, String> deviceResponseMap = new HashMap<>();
  for (DeviceDescriptor device : deviceList) {
    deviceResponseMap.put(device.getId(), device.getName());
  }
  return new ResponseEntity<>(deviceResponseMap, null, HttpStatus.OK);
}
origin: macrozheng/mall

@Override
public Page<EsProduct> search(String keyword, Long brandId, Long productCategoryId, Integer pageNum, Integer pageSize,Integer sort) {
  Pageable pageable = new PageRequest(pageNum, pageSize);
  NativeSearchQueryBuilder nativeSearchQueryBuilder = new NativeSearchQueryBuilder();
origin: armzilla/amazon-echo-ha-bridge

@RequestMapping(value = "/{userId}", method = RequestMethod.GET, produces = "application/json")
public ResponseEntity<HueApiResponse> getApi(@PathVariable(value = "userId") String userId, HttpServletRequest request) {
  log.info("hue api root requested: " + userId + " from " + request.getRemoteAddr());
  int pageNumber = request.getLocalPort()-portBase;
  Page<DeviceDescriptor> descriptorList = repository.findByDeviceType("switch", new PageRequest(pageNumber, 25));
  if (descriptorList == null) {
    return new ResponseEntity<>(null, null, HttpStatus.NOT_FOUND);
  }
  Map<String, DeviceResponse> deviceList = new HashMap<>();
  descriptorList.forEach(descriptor -> {
        DeviceResponse deviceResponse = DeviceResponse.createResponse(descriptor.getName(), descriptor.getId());
        deviceList.put(descriptor.getId(), deviceResponse);
      }
  );
  HueApiResponse apiResponse = new HueApiResponse();
  apiResponse.setLights(deviceList);
  HttpHeaders headerMap = new HttpHeaders();
  ResponseEntity<HueApiResponse> entity = new ResponseEntity<>(apiResponse, headerMap, HttpStatus.OK);
  return entity;
}
origin: apache/servicecomb-pack

 @Transactional
 @Override
 @Segment(name = "findFirstTimeout", category = "application", library = "kamon")
 public List<TxTimeout> findFirstTimeout() {
  List<TxTimeout> timeoutEvents = timeoutRepo.findFirstTimeoutTxOrderByExpireTimeAsc(new PageRequest(0, 1));
  timeoutEvents.forEach(event -> timeoutRepo
    .updateStatusByGlobalTxIdAndLocalTxId(PENDING.name(), event.globalTxId(), event.localTxId()));
  return timeoutEvents;
 }
}
origin: apache/servicecomb-pack

public void handleTimeoutTx(Date deadLine, int size) {
 tccTxEventRepository.findTimeoutGlobalTx(deadLine, TccTxType.STARTED.name(), new PageRequest(0, size))
   .ifPresent(e -> e.forEach(t -> {
    GlobalTxEvent globalTxEvent = new GlobalTxEvent(
      t.getServiceName(),
      t.getInstanceId(),
      t.getGlobalTxId(),
      t.getLocalTxId(),
      t.getParentTxId(),
      TccTxType.END_TIMEOUT.name(),
      TransactionStatus.Failed.name());
    onTccEndedEvent(globalTxEvent);
   }));
}
origin: naver/ngrinder

@SuppressWarnings("unchecked")
@Test
public void testGetTestList() {
  createPerfTest("new test1", Status.READY, new Date());
  ModelMap model = new ModelMap();
  controller.getAll(getTestUser(), null, null, null, new PageRequest(0, 10), model);
  Page<PerfTest> testPage = (Page<PerfTest>) model.get("testListPage");
  List<PerfTest> testList = testPage.getContent();
  assertThat(testList.size(), is(1));
}
origin: naver/ngrinder

@SuppressWarnings("unchecked")
@Test
public void testGetTestListByKeyWord() {
  String strangeName = "DJJHG^%R&*^%^565(^%&^%(^%(^";
  createPerfTest(strangeName, Status.READY, new Date());
  ModelMap model = new ModelMap();
  Sort sort = new Sort("testName");
  Pageable pageable = new PageRequest(0, 10, sort);
  controller.getAll(getTestUser(), strangeName, null, null, pageable, model);
  Page<PerfTest> testPage = (Page<PerfTest>) model.get("testListPage");
  List<PerfTest> testList = testPage.getContent();
  assertThat(testList.size(), is(1));
  controller.getAll(getTestUser(), strangeName.substring(2, 10), null, null, new PageRequest(0, 10), model);
  testPage = (Page<PerfTest>) model.get("testListPage");
  testList = testPage.getContent();
  assertThat(testList.size(), is(1));
}
origin: naver/ngrinder

/**
 * Test method for
 * {@link org.ngrinder.user.controller.UserController#getAll(org.springframework.ui.ModelMap, org.ngrinder.model.Role,
 * org.springframework.data.domain.Pageable, java.lang.String)}
 * .
 */
@Test
public void testGetAll() {
  Pageable page = new PageRequest(1, 10);
  ModelMap model = new ModelMap();
  userController.getAll(model, null, page, null);
  model.clear();
  userController.getAll(model, Role.ADMIN, page, null);
  model.clear();
  userController.getAll(model, null, page, "user");
}
org.springframework.data.domainPageRequest<init>

Javadoc

Creates a new PageRequest. Pages are zero indexed, thus providing 0 for page will return the first page.

Popular methods of PageRequest

  • of
  • getPageSize
  • equals
  • getPageNumber
  • hashCode
  • getSort
  • getOffset
  • previous

Popular in Java

  • Updating database using SQL prepared statement
  • orElseThrow (Optional)
    Return the contained value, if present, otherwise throw an exception to be created by the provided s
  • setScale (BigDecimal)
    Returns a BigDecimal whose scale is the specified value, and whose value is numerically equal to thi
  • getSharedPreferences (Context)
  • VirtualMachine (com.sun.tools.attach)
    A Java virtual machine. A VirtualMachine represents a Java virtual machine to which this Java vir
  • HashMap (java.util)
    HashMap is an implementation of Map. All optional operations are supported.All elements are permitte
  • Locale (java.util)
    A Locale object represents a specific geographical, political, or cultural region. An operation that
  • SortedMap (java.util)
    A map that has its keys ordered. The sorting is according to either the natural ordering of its keys
  • ConcurrentHashMap (java.util.concurrent)
    A hash table supporting full concurrency of retrievals and adjustable expected concurrency for updat
  • SSLHandshakeException (javax.net.ssl)
    The exception that is thrown when a handshake could not be completed successfully.
Codota Logo
  • Products

    Search for Java codeSearch for JavaScript codeEnterprise
  • IDE Plugins

    IntelliJ IDEAWebStormAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimAtomGoLandRubyMineEmacsJupyter
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogCodota Academy Plugin user guide Terms of usePrivacy policyJava Code IndexJavascript Code Index
Get Codota for your IDE now