I have a code like below:
Pageable pageableRequest = PageRequest.of(page, limit, Sort.by(sortBy));
Page<User> userList= null;
userList = this.user.findAll(pageableRequest)
from here I get all the data and total is shown. However, I want to group the total by status. How can I achieve that? Now total is 26 and I have 3 status inactive, active and vip.
If you want to have all users grouped by status you can do something like below.
Ask for all users and than group it in java
List<User> userList = this.user.findAll();
Map<Status, List<User>> mapResult = userList.stream()
.collect(Collectors.groupingBy(User::getStatus));