Package org.springframework.data.domain

Examples of org.springframework.data.domain.Sort


    //given
    jdbc.update("INSERT INTO USERS VALUES (?, ?, ?, ?)", "john3", SOME_DATE_OF_BIRTH, SOME_REPUTATION, true);
    jdbc.update("INSERT INTO USERS VALUES (?, ?, ?, ?)", "john5", SOME_DATE_OF_BIRTH, SOME_REPUTATION + 1, true);
    jdbc.update("INSERT INTO USERS VALUES (?, ?, ?, ?)", "john4", SOME_DATE_OF_BIRTH, SOME_REPUTATION + 1, true);
    jdbc.update("INSERT INTO USERS VALUES (?, ?, ?, ?)", "john6", SOME_DATE_OF_BIRTH, SOME_REPUTATION - 1, true);
    final Sort sort = new Sort(new Order(DESC, "reputation"), new Order(ASC, "user_name"));

    //when
    final List<User> all = repository.findAll(sort);

    //then
View Full Code Here


    final CommentWithUser first = repository.save(new CommentWithUser(someUser, "First comment", SOME_TIMESTAMP, 3));
    final CommentWithUser second = repository.save(new CommentWithUser(someUser, "Second comment", SOME_TIMESTAMP, 2));
    final CommentWithUser third = repository.save(new CommentWithUser(someUser, "Third comment", SOME_TIMESTAMP, 1));

    //when
    final List<CommentWithUser> all = repository.findAll(new Sort("favourite_count"));

    //then
    assertThat(all).containsExactly(third, second, first);
  }
View Full Code Here

    final CommentWithUser first = repository.save(new CommentWithUser(firstUser, "First comment", SOME_TIMESTAMP, 3));
    final CommentWithUser second = repository.save(new CommentWithUser(secondUser, "Second comment", SOME_TIMESTAMP, 2));
    final CommentWithUser third = repository.save(new CommentWithUser(thirdUser, "Third comment", SOME_TIMESTAMP, 1));

    //when
    final List<CommentWithUser> all = repository.findAll(new Sort(DESC, "favourite_count"));

    //then
    assertThat(all).containsExactly(first, second, third);
  }
View Full Code Here

    repository.save(new BoardingPass("BAR-100", 2, "Who", "E04"));
    repository.save(new BoardingPass("BAR-100", 1, "Gordon", "D03"));

    //when
    final List<BoardingPass> all = repository.findAll(
        new Sort(
            new Order(ASC, "flight_no"),
            new Order(DESC, "seq_no")
        )
    );
View Full Code Here

    repository.save(new BoardingPass("BAR-100", 1, "Gordon", "D03"));

    //when
    final Page<BoardingPass> page = repository.findAll(
        new PageRequest(0, 3,
            new Sort(
                new Order(ASC, "flight_no"),
                new Order(DESC, "seq_no")
            )
        ));
View Full Code Here

    repository.save(new BoardingPass("BAR-100", 1, "Gordon", "D03"));

    //when
    final Page<BoardingPass> page = repository.findAll(
        new PageRequest(1, 3,
            new Sort(
                new Order(ASC, "flight_no"),
                new Order(DESC, "seq_no")
            )
        ));
View Full Code Here

  @Autowired
  private MessageRepository messageRepository;

  public List<Message> getAllMessages()
  {
    return messageRepository.findAll(new Sort(Sort.Direction.DESC, "createdOn"));
  }
View Full Code Here

    return getAllMessages(1, size);
  }

  public List<Message> getAllMessages(int page, int size)
  {
    Pageable pageable = new PageRequest(page, size, new Sort(Sort.Direction.DESC, "createdOn"));
    return messageRepository.findAll(pageable).getContent();
  }
View Full Code Here

     */
    @Override
    public List<T> list(final PaginationConfiguration config) {
        Predicate predicate = getPredicate(config);
        Pageable pageable = new PageRequest(config.getFirstRow() / config.getNumberOfRows(), config.getNumberOfRows(),
                config.getSortField() != null ? new Sort(new Sort.Order(config.getSortDirection(), config.getSortField())) : null);
        return ((GenericRepository<T, Long>) getRepository()).findAll(predicate, pageable, config.getFetchFields()).getContent();
    }
View Full Code Here

     */
    @Override
    public List<T> list(final PaginationConfiguration config) {
        Predicate predicate = getPredicate(config);
        Pageable pageable = new PageRequest(config.getFirstRow() / config.getNumberOfRows(), config.getNumberOfRows(),
                config.getSortField() != null ? new Sort(new Sort.Order(config.getSortDirection(), config.getSortField())) : null);
        return ((GenericRepository<T, Long>) getRepository()).findAll(predicate, pageable, config.getFetchFields()).getContent();
    }
View Full Code Here

TOP

Related Classes of org.springframework.data.domain.Sort

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.