org.grails.datastore.mapping.query.Query.order()方法的使用及代码示例

x33g5p2x  于2022-01-29 转载在 其他  
字(3.2k)|赞(0)|评价(0)|浏览(258)

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

Query.order介绍

[英]Specifies the order of results
[中]指定结果的顺序

代码示例

代码示例来源:origin: org.grails/grails-datastore-gorm

/**
 * Orders by the specified property name (defaults to ascending)
 *
 * @param o The order object
 * @return This criteria
 */
@Override
public Criteria order(Query.Order o) {
  if (paginationEnabledList) {
    orderEntries.add(o);
  }
  else {
    query.order(o);
  }
  return this;
}

代码示例来源:origin: org.grails/grails-datastore-gorm

/**
 * Orders by the specified property name (defaults to ascending)
 *
 * @param propertyName The property name to order by
 * @return A Order instance
 */
public Criteria order(String propertyName) {
  Query.Order o = Query.Order.asc(propertyName);
  if (paginationEnabledList) {
    orderEntries.add(o);
  }
  else {
    query.order(o);
  }
  return this;
}

代码示例来源:origin: org.grails/grails-datastore-gorm

private static void addSimpleSort(Query q, String sort, String order, boolean ignoreCase) {
  Query.Order o;
  if (ORDER_DESC.equalsIgnoreCase(order)) {
    o = Query.Order.desc(sort);
  }
  else {
    o = Query.Order.asc(sort);
  }
  if(ignoreCase) o = o.ignoreCase();
  q.order(o);
}

代码示例来源:origin: org.grails/grails-datastore-gorm

/**
 * Orders by the specified property name and direction
 *
 * @param propertyName The property name to order by
 * @param direction Either "asc" for ascending or "desc" for descending
 *
 * @return A Order instance
 */
public Criteria order(String propertyName, String direction) {
  Query.Order o;
  if (direction.equals(CriteriaBuilder.ORDER_DESCENDING)) {
    o = Query.Order.desc(propertyName);
  }
  else {
    o = Query.Order.asc(propertyName);
  }
  if (paginationEnabledList) {
    orderEntries.add(o);
  }
  else {
    query.order(o);
  }
  return this;
}

代码示例来源:origin: org.grails/grails-datastore-gorm

public List list(Map paginateParams, Closure callable) {
  ensureQueryIsInitialized();
  paginationEnabledList = true;
  orderEntries = new ArrayList<>();
  invokeClosureNode(callable);
  populateArgumentsForCriteria(targetClass, query, paginateParams);
  for (Query.Order orderEntry : orderEntries) {
    query.order(orderEntry);
  }
  return new PagedResultList(query);
}

代码示例来源:origin: org.grails/grails-datastore-gorm

public Object doInSession(final Session session) {
    Query q = session.createQuery(clazz);
    applyAdditionalCriteria(q, additionalCriteria);
    boolean ascending = true;
    if (arguments.length > 0 && (arguments[0] instanceof Map)) {
      final Map args = new LinkedHashMap( (Map) arguments[0] );
      final Object order = args.remove(DynamicFinder.ARGUMENT_ORDER);
      if(order != null && "desc".equalsIgnoreCase(order.toString())) {
        ascending = false;
      }
      DynamicFinder.populateArgumentsForCriteria(clazz, q, args);
    }
    q.order( ascending ? Query.Order.asc(propertyName) : Query.Order.desc(propertyName));
    q.projections().distinct();
    return invokeQuery(q);
  }
});

代码示例来源:origin: org.grails/grails-datastore-gorm

query.order(order);

代码示例来源:origin: org.grails/grails-datastore-gorm-hibernate-core

@Override
public Query order(Order order) {
  super.order(order);

代码示例来源:origin: org.grails/grails-hibernate

@Override
public Query order(Order order) {
  super.order(order);
  criteria.addOrder(order.getDirection() == Order.Direction.ASC ?
    org.hibernate.criterion.Order.asc(calculatePropertyName(order.getProperty())) :
    org.hibernate.criterion.Order.desc(calculatePropertyName(order.getProperty())));
  return this;
}

相关文章