0

I am calling repository by id and pageRequest parameters but I cannot manage to sort the result. I call my repository in service layer as follow:

Sort sort = new Sort(Sort.Direction.DESC, "dateTime");
PageRequest pageRequest = new PageRequest(0, 10, sort) ;
repository.findById(id, pageRequest);

And here is my repository class:

public interface QueryResultRepository extends CrudRepository<QueryResult, String>{
    Page<QueryResult> findById(String id, Pageable pageable);
}

Entity Class:

@RedisHash("queryresultdataredis")
public class QueryResultDataRedis {

    @Id
    private String id = null;
    @Indexed
    private String queryId = null;
    private String name;

enter image description here

Ersoy
  • 8,816
  • 6
  • 34
  • 48
gabi
  • 1,324
  • 4
  • 22
  • 47
  • It's all a bit weird since `findById` is supposed to return one entity by its primary ID (unique) or null. But please add your Entity class to see a bit clearer. – msp Nov 29 '18 at 13:22
  • added it below the question. In fact the id is not unique – gabi Nov 29 '18 at 14:19
  • I noticed that Redis doesn't provide sorting functionality. – gabi Dec 04 '18 at 14:54

0 Answers0