本文整理了Java中javax.persistence.criteria.CriteriaQuery.isDistinct()
方法的一些代码示例,展示了CriteriaQuery.isDistinct()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。CriteriaQuery.isDistinct()
方法的具体详情如下:
包路径:javax.persistence.criteria.CriteriaQuery
类名称:CriteriaQuery
方法名:isDistinct
暂无
代码示例来源:origin: spring-projects/spring-data-jpa
@SuppressWarnings("rawtypes")
private static Expression getCountQuery(CriteriaQuery<?> query, CriteriaBuilder builder, Root<?> root) {
return query.isDistinct() ? builder.countDistinct(root) : builder.count(root);
}
}
代码示例来源:origin: spring-projects/spring-data-jpa
/**
* Creates a new count query for the given {@link Specification}.
*
* @param spec can be {@literal null}.
* @param domainClass must not be {@literal null}.
* @return
*/
protected <S extends T> TypedQuery<Long> getCountQuery(@Nullable Specification<S> spec, Class<S> domainClass) {
CriteriaBuilder builder = em.getCriteriaBuilder();
CriteriaQuery<Long> query = builder.createQuery(Long.class);
Root<S> root = applySpecificationToCriteria(spec, domainClass, query);
if (query.isDistinct()) {
query.select(builder.countDistinct(root));
} else {
query.select(builder.count(root));
}
// Remove all Orders the Specifications might have applied
query.orderBy(Collections.<Order> emptyList());
return em.createQuery(query);
}
代码示例来源:origin: katharsis-project/katharsis-framework
@Override
protected boolean isDistinct() {
return query.isDistinct();
}
代码示例来源:origin: jkazama/sample-boot-micro
@SuppressWarnings("unchecked")
public CriteriaQuery<Long> resultCount(Function<CriteriaQuery<?>, CriteriaQuery<?>> extension) {
CriteriaQuery<Long> q = builder.createQuery(Long.class);
q.from(clazz).alias(alias);
q.where(predicates.toArray(new Predicate[0]));
if (q.isDistinct()) {
q.select(builder.countDistinct(root));
} else {
q.select(builder.count(root));
}
return (CriteriaQuery<Long>)extension.apply(q);
}
代码示例来源:origin: com.blazebit/blaze-persistence-integration-spring-data-base
@Override
protected CriteriaQuery<Object> complete(Predicate predicate, Sort sort, CriteriaQuery<Object> query,
CriteriaBuilder builder, Root<?> root) {
CriteriaQuery<Object> select = query.select(query.isDistinct() ? builder.countDistinct(root) : builder.count(root));
return predicate == null ? select : select.where(predicate);
}
}
代码示例来源:origin: Blazebit/blaze-persistence
@Override
protected CriteriaQuery<Object> complete(Predicate predicate, Sort sort, CriteriaQuery<Object> query,
CriteriaBuilder builder, Root<?> root) {
CriteriaQuery<Object> select = query.select(query.isDistinct() ? builder.countDistinct(root) : builder.count(root));
return predicate == null ? select : select.where(predicate);
}
}
代码示例来源:origin: alibaba/sca-best-practice
protected <T> TypedQuery<Long> getCountQuery(Class<T> clazz, @Nullable Specification<T> spec) {
CriteriaBuilder builder = entityManager.getCriteriaBuilder();
CriteriaQuery<Long> query = builder.createQuery(Long.class);
Root<T> root = applySpecificationToCriteria(clazz, spec, query);
if (query.isDistinct()) {
query.select(builder.countDistinct(root));
} else {
query.select(builder.count(root));
}
// Remove all Orders the Specifications might have applied
query.orderBy(Collections.<Order>emptyList());
return entityManager.createQuery(query);
}
代码示例来源:origin: com.thinkbiganalytics.kylo/kylo-operational-metadata-jpa
@Override
public <S, T, ID extends Serializable> CriteriaQuery<Long> getCountQuery(EntityManager entityManager, JpaEntityInformation<T, ID> entityInformation, Specification<S> spec, Class<S> domainClass) {
CriteriaBuilder builder = entityManager.getCriteriaBuilder();
CriteriaQuery<Long> query = builder.createQuery(Long.class);
Root<S> root = query.from(domainClass);
if (query.isDistinct()) {
query.select(builder.countDistinct(root));
} else {
query.select(builder.count(root));
}
Specification<S> secured = this.augment(spec, domainClass, entityInformation);
query.where(secured.toPredicate(root, query, builder));
return query;
}
代码示例来源:origin: org.springframework.data/spring-data-jpa
@SuppressWarnings("rawtypes")
private static Expression getCountQuery(CriteriaQuery<?> query, CriteriaBuilder builder, Root<?> root) {
return query.isDistinct() ? builder.countDistinct(root) : builder.count(root);
}
}
代码示例来源:origin: org.springframework.data/spring-data-jpa
/**
* Creates a new count query for the given {@link Specification}.
*
* @param spec can be {@literal null}.
* @param domainClass must not be {@literal null}.
* @return
*/
protected <S extends T> TypedQuery<Long> getCountQuery(@Nullable Specification<S> spec, Class<S> domainClass) {
CriteriaBuilder builder = em.getCriteriaBuilder();
CriteriaQuery<Long> query = builder.createQuery(Long.class);
Root<S> root = applySpecificationToCriteria(spec, domainClass, query);
if (query.isDistinct()) {
query.select(builder.countDistinct(root));
} else {
query.select(builder.count(root));
}
// Remove all Orders the Specifications might have applied
query.orderBy(Collections.<Order> emptyList());
return em.createQuery(query);
}
代码示例来源:origin: com.intoverflow.booster/booster-core
/**
* Creates a new count query for the given {@link org.springframework.data.jpa.domain.Specification}.
*
* @param spec can be {@literal null}.
* @return
*/
@Override
protected TypedQuery<Long> getCountQuery(Specification<M> spec) {
CriteriaBuilder builder = em.getCriteriaBuilder();
CriteriaQuery<Long> query = builder.createQuery(Long.class);
Root<M> root = applySpecificationToCriteria(spec, query);
if (query.isDistinct()) {
query.select(builder.countDistinct(root));
} else {
query.select(builder.count(root));
}
TypedQuery<Long> q = em.createQuery(query);
repositoryHelper.applyEnableQueryCache(q);
return q;
}
代码示例来源: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());
}
内容来源于网络,如有侵权,请联系作者删除!