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

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

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

Query.projections介绍

暂无

代码示例

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

/**
 * Defines projections
 *
 * @param callable The closure defining the projections
 * @return The projections list
 */
public ProjectionList projections(Closure callable) {
  projectionList = query.projections();
  invokeClosureNode(callable);
  return projectionList;
}

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

protected void initialize() {
  if (totalCount == Integer.MIN_VALUE) {
    if (query == null) {
      totalCount = 0;
    } else {
      Query newQuery = (Query)query.clone();
      newQuery.projections().count();
      Number result = (Number) newQuery.singleResult();
      totalCount = result == null ? 0 : result.intValue();
    }
  }
}

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

/**
 * Defines and executes a list distinct query in a single call. Example: Foo.createCriteria.listDistinct { }
 * @param callable The closure to execute
 *
 * @return The result list
 */
public List listDistinct(Closure callable) {
  ensureQueryIsInitialized();
  invokeClosureNode(callable);
  query.projections().distinct();
  return query.list();
}

代码示例来源: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

/**
 * Defines and executes a count query in a single call. Example: Foo.createCriteria.count { }
 * @param callable The closure to execute
 *
 * @return The result count
 */
public Number count(Closure callable) {
  ensureQueryIsInitialized();
  invokeClosureNode(callable);
  uniqueResult = true;
  query.projections().count();
  return (Number) query.singleResult();
}

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

query.projections().add(projection);

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

@Override
public List query(Object primaryKey) {
  Association inverseSide = association.getInverseSide();
  Query query = session.createQuery(association.getAssociatedEntity().getJavaClass());
  query.eq(inverseSide.getName(), primaryKey);
  query.projections().id();
  return query.list();
}

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

protected Query buildQuery(DynamicFinderInvocation invocation, Class<?> clazz, Query q) {
    applyAdditionalCriteria(q, invocation.getCriteria());
    configureQueryWithArguments(clazz, q, invocation.getArguments());

    String operatorInUse = invocation.getOperator();
    if (operatorInUse != null && operatorInUse.equals(OPERATOR_OR)) {
      Query.Junction disjunction = q.disjunction();

      for (MethodExpression expression : invocation.getExpressions()) {
        q.add(disjunction, expression.createCriterion());
      }
    }
    else {
      for (MethodExpression expression : invocation.getExpressions()) {
        q.add( expression.createCriterion() );
      }
    }

    q.projections().count();
    return q;
  }
}

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

protected Query buildQuery(DynamicFinderInvocation invocation, Class<?> clazz, Query query) {
    applyAdditionalCriteria(query, invocation.getCriteria());
    applyDetachedCriteria(query, invocation.getDetachedCriteria());
    configureQueryWithArguments(clazz, query, invocation.getArguments());

    final String operatorInUse = invocation.getOperator();
    if (operatorInUse != null && operatorInUse.equals(OPERATOR_OR)) {
      if (firstExpressionIsRequiredBoolean()) {
        MethodExpression expression = invocation.getExpressions().remove(0);
        query.add(expression.createCriterion());
      }
      Query.Junction disjunction = query.disjunction();

      for (MethodExpression expression : invocation.getExpressions()) {
        query.add(disjunction, expression.createCriterion());
      }
    }
    else {
      for (MethodExpression expression : invocation.getExpressions()) {
        query.add( expression.createCriterion() );
      }
    }
    query.projections().distinct();
    return query;
  }
}

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

.projections().id();

相关文章