本文整理了Java中javax.persistence.criteria.CriteriaQuery.having()
方法的一些代码示例,展示了CriteriaQuery.having()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。CriteriaQuery.having()
方法的具体详情如下:
包路径:javax.persistence.criteria.CriteriaQuery
类名称:CriteriaQuery
方法名:having
[英]Specify a restriction over the groups of the query. Replaces the previous having restriction(s), if any. This method only overrides the return type of the corresponding AbstractQuery method.
[中]指定对查询组的限制。替换以前的限制(如果有)。此方法仅重写相应AbstractQuery方法的返回类型。
代码示例来源:origin: JoleneOL/market-manage
@Override
public List<Depot> usableDepotFor(BiFunction<CriteriaBuilder, Root<UsageStock>, Predicate> condition) {
final CriteriaBuilder cb = entityManager.getCriteriaBuilder();
CriteriaQuery<Depot> cq = cb.createQuery(Depot.class);
Root<UsageStock> root = cq.from(UsageStock.class);
return entityManager.createQuery(cq
.select(root.get(UsageStock_.depot))
.groupBy(root.get(UsageStock_.depot))
.having(condition == null ? cb.conjunction() : condition.apply(cb, root))
.distinct(true)
)
.getResultList();
}
代码示例来源:origin: com.netflix.genie/genie-core
predicates.add(tagEntityJoin.in(tags));
cq.groupBy(root.get(CommandEntity_.id));
cq.having(cb.equal(cb.count(root.get(CommandEntity_.id)), tags.size()));
代码示例来源:origin: com.netflix.genie/genie-core
predicates.add(tagEntityJoin.in(tags));
cq.groupBy(root.get(ClusterEntity_.id));
cq.having(cb.equal(cb.count(root.get(ClusterEntity_.id)), tags.size()));
代码示例来源:origin: com.netflix.genie/genie-core
predicates.add(tagEntityJoin.in(tags));
cq.groupBy(root.get(ApplicationEntity_.id));
cq.having(cb.equal(cb.count(root.get(ApplicationEntity_.id)), tags.size()));
代码示例来源:origin: xautlx/s2jh4net
if (ArrayUtils.isNotEmpty(havingPredicates)) {
Predicate having = criteriaBuilder.and(havingPredicates);
select.having(having);
代码示例来源:origin: org.jboss.pressgang.ccms/pressgang-ccms-query
/**
* Copy Criteria without Selection
*
* @param from source Criteria
* @param to destination Criteria
*/
public static void copyCriteriaNoSelection(CriteriaQuery<?> from, CriteriaQuery<?> to) {
// Copy Roots
for (Root<?> root : from.getRoots()) {
Root<?> dest = to.from(root.getJavaType());
dest.alias(getOrCreateAlias(root));
copyJoins(root, dest);
}
if (from.getGroupList() != null) to.groupBy(from.getGroupList());
to.distinct(from.isDistinct());
if (from.getGroupRestriction() != null) to.having(from.getGroupRestriction());
if (from.getRestriction() != null) to.where(from.getRestriction());
if (from.getOrderList() != null) to.orderBy(from.getOrderList());
}
内容来源于网络,如有侵权,请联系作者删除!