Based on question How to return a custom object from a Spring Data JPA GROUP BY query, my custom query is working, as follows:
@Query("select new br.com.cwidevs.dto.Goleador(j.id, sum(pj.gols)) from PartidaJogador pj join pj.id.jogador j group by j.id")
public List<Goleador> getGoleadores();
Here is the simple bean class:
public class Goleador {
private Long jogador;
private Long totalGols;
}
At this point, how to implement ORDER BY
? Can I achieve thi with Sort?