Get last records ordered by date on Spring Data

Turns out that the signature of the method was incorrect. The right one is:

findFirst5ByOrderByPublicationDateDesc()

Is a little confusing because in the official samples they have this:

List<User> findTop10ByLastname(String lastname, Pageable pageable);

As you can see there is only one By there, the usual one.

Leave a Comment