How to sort by multiple properties in Spring Data (JPA) derived queries?

The trick is to simply delimit the properties you want to sort by using the direction keywords Asc and Desc. So what you probably want in your query method is something like:

…OrderByProgDateAscStartTimeAsc

Note, how we conclude the first property definition by Asc and keep going with the next property.

Generally speaking, we recommend switching to @Query based queries, once method names exceed a certain length or complexity. The main reason being that it’s awkward for clients to call these very long methods. With @Query you rather get the full power of the query language plus a reasonably sized method name that might be of higher level language to express the intent of the query.

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)