当前位置: 首页>>代码示例>>Java>>正文


Java Subquery.groupBy方法代码示例

本文整理汇总了Java中javax.persistence.criteria.Subquery.groupBy方法的典型用法代码示例。如果您正苦于以下问题:Java Subquery.groupBy方法的具体用法?Java Subquery.groupBy怎么用?Java Subquery.groupBy使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在javax.persistence.criteria.Subquery的用法示例。


在下文中一共展示了Subquery.groupBy方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getChanges

import javax.persistence.criteria.Subquery; //导入方法依赖的package包/类
@Override
public List<RegistryOperation> getChanges(Date from, Date until) {
    CriteriaQuery<RegistryOperation> query = criteriaBuilder.createQuery(RegistryOperation.class);
    Root<RegistryOperation> root = query.from(clazz);
    Subquery<Long> subquery = query.subquery(Long.class);
    Root<RegistryOperation> subqueryRoot = subquery.from(clazz);
    subquery = subquery.select(criteriaBuilder.max(subqueryRoot.get(RegistryOperation_.id)));
    Predicate subqueryPredicate = criteriaBuilder.isTrue(subqueryRoot.get(RegistryOperation_.exposed));
    subqueryPredicate = criteriaBuilder.and(subqueryPredicate,
        criteriaBuilder.lessThanOrEqualTo(subqueryRoot.get(RegistryOperation_.date), until));
    if (from != null) {
        subqueryPredicate = criteriaBuilder.and(subqueryPredicate,
            criteriaBuilder.greaterThanOrEqualTo(subqueryRoot.get(RegistryOperation_.date), from));
    }
    subquery = subquery.where(subqueryPredicate);
    subquery = subquery.groupBy(subqueryRoot.get(RegistryOperation_.target).get(SemanticDescriptor_.id));
    query = query.where(root.get(RegistryOperation_.id).in(subquery));
    query.orderBy(criteriaBuilder.asc(root.get(RegistryOperation_.date)));
    return entityManager.createQuery(query).getResultList();
}
 
开发者ID:psnc-dl,项目名称:darceo,代码行数:21,代码来源:RegistryOperationDaoBean.java

示例2: hasProperties

import javax.persistence.criteria.Subquery; //导入方法依赖的package包/类
public WordTemplateQuery hasProperties(Map<String, String> someProperties) {
	Subquery<Long> subQuery = query.subquery(Long.class);
	Root<PersistentTemplate> fromSubQuery = subQuery
			.from(PersistentTemplate.class);
	Path<Long> id = fromSubQuery.get("id");
	subQuery.select(id);
	MapJoin<PersistentTemplate, String, String> propertiesMap = fromSubQuery
			.joinMap("properties", JoinType.INNER);
	subQuery.where(buildPropertyRestriction(propertiesMap, someProperties));
	subQuery.groupBy(id);
	subQuery.having(criteriaBuilder.equal(criteriaBuilder.count(id),
			someProperties.size()));
	restrictions.add(persistentTemplate.get("id").in(subQuery));
	return this;
}
 
开发者ID:wte4j,项目名称:wte4j,代码行数:16,代码来源:WordTemplateQuery.java

示例3: getChanges

import javax.persistence.criteria.Subquery; //导入方法依赖的package包/类
@Override
public List<Operation> getChanges(Date from, Date until, NamespaceType prefix, ObjectType set, int offset,
        int pageSize) {
    CriteriaQuery<Operation> query = criteriaBuilder.createQuery(Operation.class);
    Root<Operation> root = query.from(clazz);
    Subquery<Long> subquery = query.subquery(Long.class);
    Root<Operation> subqueryRoot = subquery.from(clazz);
    subquery = subquery.select(criteriaBuilder.max(subqueryRoot.get(Operation_.id)));
    Predicate subqueryPredicate = criteriaBuilder.greaterThanOrEqualTo(subqueryRoot.get(Operation_.date), from);
    subqueryPredicate = criteriaBuilder.and(subqueryPredicate,
        criteriaBuilder.lessThanOrEqualTo(subqueryRoot.get(Operation_.date), until));
    subqueryPredicate = criteriaBuilder.and(subqueryPredicate,
        criteriaBuilder.equal(subqueryRoot.get(Operation_.metadataType), prefix));
    if (set != null) {
        Join<Operation, DigitalObject> operationToObject = subqueryRoot.join(Operation_.object);
        subqueryPredicate = criteriaBuilder.and(subqueryPredicate,
            criteriaBuilder.equal(operationToObject.get(DigitalObject_.type), set));
    }
    subquery = subquery.where(subqueryPredicate);
    subquery = subquery.groupBy(subqueryRoot.get(Operation_.object).get(DigitalObject_.id));
    query = query.where(root.get(Operation_.id).in(subquery));
    query.orderBy(criteriaBuilder.asc(root.get(Operation_.id)));
    return entityManager.createQuery(query).setFirstResult(offset).setMaxResults(pageSize).getResultList();
}
 
开发者ID:psnc-dl,项目名称:darceo,代码行数:25,代码来源:OperationDaoBean.java


注:本文中的javax.persistence.criteria.Subquery.groupBy方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。