提交 8a0f6fbe 编写于 作者: O o2sword

distinct问题修复

上级 1a266890
package com.x.portal.assemble.designer.factory;
import java.util.List;
import java.util.stream.Collectors;
import javax.persistence.EntityManager;
import javax.persistence.criteria.CriteriaBuilder;
......@@ -82,8 +83,8 @@ public class TemplatePageFactory extends AbstractFactory {
p = cb.isMember(effectivePerson.getDistinguishedName(), root.get(TemplatePage_.controllerList));
p = cb.or(p, cb.equal(root.get(TemplatePage_.creatorPerson), effectivePerson.getDistinguishedName()));
}
cq.select(root.get(TemplatePage_.id)).where(p).distinct(true);
List<String> list = em.createQuery(cq.select(root.get(TemplatePage_.id)).where(p)).getResultList();
cq.select(root.get(TemplatePage_.id)).where(p);
List<String> list = em.createQuery(cq).getResultList().stream().distinct().collect(Collectors.toList());
return list;
}
......@@ -98,8 +99,8 @@ public class TemplatePageFactory extends AbstractFactory {
cb.or(cb.isMember(effectivePerson.getDistinguishedName(), root.get(TemplatePage_.controllerList)),
cb.equal(root.get(TemplatePage_.creatorPerson), effectivePerson.getDistinguishedName())));
}
cq.select(root.get(TemplatePage_.id)).where(p).distinct(true);
List<String> list = em.createQuery(cq.select(root.get(TemplatePage_.id)).where(p)).getResultList();
cq.select(root.get(TemplatePage_.id)).where(p);
List<String> list = em.createQuery(cq).getResultList().stream().distinct().collect(Collectors.toList());
return list;
}
......
......@@ -53,7 +53,7 @@ abstract class BaseAction extends StandardJaxrsAction {
CriteriaQuery<Portal> cq = cb.createQuery(Portal.class);
Root<Portal> root = cq.from(Portal.class);
Predicate p = cb.equal(root.get(Portal_.alias), alias);
List<Portal> os = em.createQuery(cq.select(root).where(p).distinct(true)).getResultList();
List<Portal> os = em.createQuery(cq.select(root).where(p)).getResultList();
if (os.size() == 1) {
return os.get(0);
} else {
......@@ -70,7 +70,7 @@ abstract class BaseAction extends StandardJaxrsAction {
CriteriaQuery<Portal> cq = cb.createQuery(Portal.class);
Root<Portal> root = cq.from(Portal.class);
Predicate p = cb.equal(root.get(Portal_.name), name);
List<Portal> os = em.createQuery(cq.select(root).where(p).distinct(true)).getResultList();
List<Portal> os = em.createQuery(cq.select(root).where(p)).getResultList();
if (os.size() == 1) {
return os.get(0);
} else {
......
......@@ -56,8 +56,8 @@ class ActionListSummaryWithPortalCategory extends BaseAction {
p = cb.or(p, cb.equal(root.get(Portal_.creatorPerson), effectivePerson.getDistinguishedName()));
}
p = cb.and(p, cb.equal(root.get(Portal_.portalCategory), Objects.toString(portalCategory, "")));
cq.select(root.get(Portal_.id)).where(p).distinct(true);
List<String> list = em.createQuery(cq.select(root.get(Portal_.id)).where(p)).getResultList();
cq.select(root.get(Portal_.id)).where(p);
List<String> list = em.createQuery(cq).getResultList().stream().distinct().collect(Collectors.toList());
return list;
}
......
......@@ -2,6 +2,7 @@ package com.x.portal.assemble.designer.jaxrs.portal;
import java.util.List;
import java.util.Objects;
import java.util.stream.Collectors;
import javax.persistence.EntityManager;
import javax.persistence.criteria.CriteriaBuilder;
......@@ -60,8 +61,8 @@ abstract class BaseAction extends StandardJaxrsAction {
p = cb.isMember(effectivePerson.getDistinguishedName(), root.get(Portal_.controllerList));
p = cb.or(p, cb.equal(root.get(Portal_.creatorPerson), effectivePerson.getDistinguishedName()));
}
cq.select(root.get(Portal_.id)).where(p).distinct(true);
List<String> list = em.createQuery(cq.select(root.get(Portal_.id)).where(p)).getResultList();
cq.select(root.get(Portal_.id)).where(p);
List<String> list = em.createQuery(cq).getResultList().stream().distinct().collect(Collectors.toList());
return list;
}
......@@ -77,8 +78,8 @@ abstract class BaseAction extends StandardJaxrsAction {
p = cb.or(p, cb.equal(root.get(Portal_.creatorPerson), effectivePerson.getDistinguishedName()));
}
p = cb.and(p, cb.equal(root.get(Portal_.portalCategory), Objects.toString(portalCategory, "")));
cq.select(root.get(Portal_.id)).where(p).distinct(true);
List<String> list = em.createQuery(cq.select(root.get(Portal_.id)).where(p)).getResultList();
cq.select(root.get(Portal_.id)).where(p);
List<String> list = em.createQuery(cq).getResultList().stream().distinct().collect(Collectors.toList());
return list;
}
......
......@@ -19,6 +19,7 @@ import com.x.base.core.project.cache.Cache.CacheCategory;
import com.x.base.core.project.cache.Cache.CacheKey;
import com.x.base.core.project.cache.CacheManager;
import java.util.Optional;
import java.util.stream.Collectors;
public class PortalFactory extends AbstractFactory {
......@@ -47,8 +48,8 @@ public class PortalFactory extends AbstractFactory {
p = cb.or(p, root.get(Portal_.availableIdentityList).in(identities));
p = cb.or(p, root.get(Portal_.availableUnitList).in(units));
}
cq.select(root.get(Portal_.id)).where(p).distinct(true);
return em.createQuery(cq).getResultList();
cq.select(root.get(Portal_.id)).where(p);
return em.createQuery(cq).getResultList().stream().distinct().collect(Collectors.toList());
}
public boolean visible(EffectivePerson effectivePerson, Portal portal) throws Exception {
......
......@@ -70,8 +70,8 @@ class ActionList extends BaseAction {
who = cb.or(who, root.get(Portal_.availableUnitList).in(units));
p = cb.and(p, who);
}
cq.select(root.get(Portal_.id)).where(p).distinct(true);
return em.createQuery(cq).getResultList();
cq.select(root.get(Portal_.id)).where(p);
return em.createQuery(cq).getResultList().stream().distinct().collect(Collectors.toList());
}
public static class Wo extends Portal {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册