1

I want to get a page of results using follwing Java code:

Page<MyDTO> page = repo.findAllOrderByCreatedDate(new PageRequest(pageNumber,pageSize));

In MyDTO I have:

@Entity
class MyDTO{

  @Id
  private Long id;

  private LocalDateTime createdDate;

  //getters setters
}

What I get is:

No parameter available for part createdDate SIMPLE_PROPERTY (1):
[Is, Equals].; nested exception is java.lang.IllegalArgumentException:

How to combine paging and sortig with Spring Data?

jarosik
  • 4,136
  • 10
  • 36
  • 53
  • 1
    I think the problem is that Hibernate (prior to version 5) doesn't natively support persisting of LocalDateTime. Check out https://stackoverflow.com/questions/1616280/java-solutions-for-distributed-transactions-and-or-data-shared-in-cluster – Nikolai Shevchenko Mar 20 '18 at 14:00

1 Answers1

3

You can use another constructor of class PageRequest:

Page<MyDTO> page = repo.findAll(new PageRequest(pageNumber,pageSize, new Sort("createdDate")));
pDer666
  • 707
  • 5
  • 22