List<Credential> credentials = SqlUtil.getMapToList(entityManager, stringBuilder.toString(), Credential.class);
List<List<Credential>> groupList = new ArrayList<>();
credentials.stream().collect(Collectors.groupingBy(Credential::getPaymentMethod, Collectors.toList()))
.forEach((paymentMethod, fooListByName) -> groupList.add(fooListByName));