javax.persistence.criteria.CriteriaQuery.getOrderList()方法的使用及代码示例

x33g5p2x  于2022-01-18 转载在 其他  
字(5.2k)|赞(0)|评价(0)|浏览(165)

本文整理了Java中javax.persistence.criteria.CriteriaQuery.getOrderList()方法的一些代码示例,展示了CriteriaQuery.getOrderList()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。CriteriaQuery.getOrderList()方法的具体详情如下:
包路径:javax.persistence.criteria.CriteriaQuery
类名称:CriteriaQuery
方法名:getOrderList

CriteriaQuery.getOrderList介绍

[英]Return the ordering expressions in order of precedence. Returns empty list if no ordering expressions have been specified. Modifications to the list do not affect the query.
[中]按优先顺序返回排序表达式。如果未指定排序表达式,则返回空列表。对列表的修改不会影响查询。

代码示例

代码示例来源:origin: katharsis-project/katharsis-framework

@Override
public List<Order> getOrderList() {
  return new ArrayList<>(criteriaQuery.getOrderList());
}

代码示例来源:origin: Impetus/Kundera

List<Order> orderings = criteriaQuery.getOrderList();

代码示例来源:origin: org.kuali.rice/rice-krad-data

/**
 * {@inheritDoc}
 */
@Override
protected void addOrderBy(TranslationContext criteria, String propertyPath, boolean sortAscending) {
  List<Order> orderList = criteria.query.getOrderList();
  if (orderList == null) {
    orderList = new ArrayList<Order>();
  }
  if (propertyPath.contains(".")) {
    String propertyPathStart = StringUtils.substringBefore( propertyPath, "." );
    String propertyPathEnd = StringUtils.substringAfter( propertyPath, "." );
    if (sortAscending) {
      orderList.add(criteria.builder.asc(criteria.root.get(propertyPathStart).get(propertyPathEnd)));
    } else {
      orderList.add(criteria.builder.desc(criteria.root.get(propertyPathStart).get(propertyPathEnd)));
    }
  } else {
    if (sortAscending) {
      orderList.add(criteria.builder.asc(criteria.root.get(propertyPath)));
    } else {
      orderList.add(criteria.builder.desc(criteria.root.get(propertyPath)));
    }
  }
  criteria.query.orderBy(orderList);
}

代码示例来源:origin: katharsis-project/katharsis-framework

@Override
@SuppressWarnings({ "rawtypes" })
public long getTotalRowCount() {
  Selection<T> selection = query.getSelection();
  List<Order> orderList = query.getOrderList();
  try {
    CriteriaBuilder builder = em.getCriteriaBuilder();
    Expression<Long> countExpr;
    Set<Root<?>> roots = query.getRoots();
    if (roots.size() != 1) {
      throw new IllegalStateException("cannot compute totalRowCount in case of multiple query roots");
    }
    if (!query.getGroupList().isEmpty()) {
      throw new IllegalStateException("cannot compute totalRowCount for grouped queries");
    }
    // transform query to a count query
    Root root = roots.iterator().next();
    countExpr = builder.count(root);
    query.multiselect(countExpr);
    query.orderBy(new ArrayList<Order>());
    TypedQuery countQuery = em.createQuery(query);
    return (Long) countQuery.getSingleResult();
  }
  finally {
    // transform count query back to regular query
    query.multiselect(selection);
    query.orderBy(orderList);
  }
}

代码示例来源:origin: com.introproventures/graphql-jpa-query-schema

if (query.getOrderList() == null || query.getOrderList().isEmpty()) {
  EntityType<T> entityType = from.getModel();
  try {

代码示例来源:origin: com.walterjwhite.infrastructure.datastore.modules/google-guice-persist-criteria-builder

/** Use ES here, it would be more efficient. */
 public void search() {
  //    criteriaBuilder.equal()
  CriteriaQuery<Long> criteriaQuery = null;
  criteriaQuery.getParameters();
  criteriaQuery.getGroupList();
  criteriaQuery.getOrderList();
  criteriaQuery.getGroupRestriction();
  criteriaQuery.getRestriction();
  criteriaQuery.getSelection();

  final Predicate predicate = null;
 }
}

代码示例来源:origin: com.introproventures/graphql-jpa-query-schema

/**
 * if query orders are empty, then apply default ascending ordering
 * by root id attribute to prevent paging inconsistencies
 *
 * @param query
 * @param from
 * @param cb
 */
protected void mayBeAddDefaultOrderBy(CriteriaQuery<?> query, From<?,?> from, CriteriaBuilder cb) {
  if (query.getOrderList() == null || query.getOrderList().isEmpty()) {
    EntityType<?> fromEntityType = entityType;
    try {
      java.lang.reflect.Field sortField = getSortAnnotation(fromEntityType.getBindableJavaType());
      if (sortField == null)
        query.orderBy(cb.asc(from.get(fromEntityType.getId(fromEntityType.getIdType().getJavaType()).getName())));
      else {
        GraphQLDefaultOrderBy order = sortField.getAnnotation(GraphQLDefaultOrderBy.class);
        if (order.asc()) {
          query.orderBy(cb.asc(from.get(sortField.getName())));
        } else {
          query.orderBy(cb.desc(from.get(sortField.getName())));
        }
      }
    } catch (Exception ex) {
      //log.warn("In" + this.getClass().getName(), ex);
    }
  }
}

代码示例来源: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());
}

代码示例来源:origin: org.aksw.jena-sparql-api/jena-sparql-api-mapper

for(Order order : criteriaQuery.getOrderList()) {
  VExpression<?> x = ((OrderImpl)order).getExpression();
  Expr e = x.accept(orderCompiler);

代码示例来源:origin: SmartDataAnalytics/jena-sparql-api

for(Order order : criteriaQuery.getOrderList()) {
  VExpression<?> x = ((OrderImpl)order).getExpression();
  Expr e = x.accept(orderCompiler);

相关文章