Mam taką listę obiektów:
List<MyList> mylist = findBy....();
[
{
"bookNumber": 333
"author": 1,
},
{
"bookNumber": 22223,
"author": 1,
},
{
"bookNumber": 15,
"author": 1,
},
{
"bookNumber": 143,
"author": 3,
},
{
"bookNumber": 21234,
"author": 2,
}
]
Jak uzyskać taki wynik: czyli grupuje po author i countBook - to ilość książek dla danego autora
Klasa dto
public class Result{
private Integer authorNumber;
private Integer countBook;
}
[
{
"authorNumber": 1,
"countBook": 3,
},
{
"authorNumber": 2,
"countBook": 1,
},
{
"authorNumber": 3,
"countBook": 1,
}
]