Order By Date ASC with Spring Data

MaximeF picture MaximeF · Nov 1, 2013 · Viewed 58.1k times · Source

I try to make an application with Spring-Data-JPA on a table in order by ASC but it gives me an error:

Invalid derived query! No property asc found for type java.util.Calendar

Why ?

List<Foo> findAllOrderByDateAsc();

or

@Query("SELECT * FROM foo ORDER BY date ASC")
List<Foo> findAllOrderByDateAsc();

Answer

Johnny Lim picture Johnny Lim · Feb 4, 2014

Try to add "By" between "All" and "Order" like this:

List<Foo> findAllByOrderByDateAsc();