Commit fcdab332 by Antti Tonkyra

HM

1 parent b2e4836a
......@@ -2,6 +2,8 @@ package fi.codecrew.moya.facade;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import javax.ejb.EJB;
......@@ -99,8 +101,7 @@ public class PrintedCardFacade extends IntegerPkGenericFacade<PrintedCard> {
CriteriaBuilder cb = getEm().getCriteriaBuilder();
CriteriaQuery<PrintedCard> cq = cb.createQuery(PrintedCard.class);
Root<PrintedCard> root = cq.from(PrintedCard.class);
cq.select(root).distinct(true);
List<Predicate> preds = new ArrayList<Predicate>();
preds.add(cb.equal(root.get(PrintedCard_.event), eventbean.getCurrentEvent()));
......@@ -112,7 +113,14 @@ public class PrintedCardFacade extends IntegerPkGenericFacade<PrintedCard> {
cq.where(preds.toArray(new Predicate[preds.size()]));
cq.orderBy(cb.asc(root.get(PrintedCard_.user)), cb.asc(root.get(PrintedCard_.template).get(CardTemplate_.power)));
return getEm().createQuery(cq).getResultList();
List<PrintedCard> pcl = getEm().createQuery(cq).getResultList();
HashMap<Integer, PrintedCard> pch = new HashMap<>();
for(PrintedCard pc : pcl) {
pch.put(pc.getUser().getId(), pc);
}
return new ArrayList<PrintedCard>(pch.values());
}
}
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!