Works with native query now needst to be hql

This commit is contained in:
BuildTools
2020-11-22 03:51:24 +01:00
parent 9d3500c1fb
commit 0130fb77e1
6 changed files with 40 additions and 8 deletions

View File

@ -1,7 +1,10 @@
package com.plannaplan.services;
import java.util.HashMap;
import java.util.List;
import java.util.Objects;
import java.util.Optional;
import java.util.stream.Collectors;
import com.plannaplan.entities.Groups;
import com.plannaplan.repositories.GroupRepository;
@ -51,7 +54,17 @@ public class GroupService {
}
public int getAssignedAmount(Long groupId) {
return this.repo.getAssignedAmount(groupId).orElse(Integer.valueOf(0)).intValue();
public HashMap<Groups, Integer> getTakenPlaces(List<Groups> groups) {
HashMap<Groups, Integer> respoonse = new HashMap<>();
// groups.forEach(group -> {
// final Long id = group.getId();
// final Integer ammount =
// this.repo.getAssignedAmount(id).orElse(Integer.valueOf(0)).intValue();
// respoonse.put(group, ammount);
// });
List<Object[]> respoonse2 = this.repo.getAssignedAmounts(
groups.stream().filter(Objects::nonNull).map(Groups::getId).collect(Collectors.toList()));
return respoonse;
}
}