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

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

本文整理了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

  1. /**
  2. * Defines projections
  3. *
  4. * @param callable The closure defining the projections
  5. * @return The projections list
  6. */
  7. public ProjectionList projections(Closure callable) {
  8. projectionList = query.projections();
  9. invokeClosureNode(callable);
  10. return projectionList;
  11. }

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

  1. protected void initialize() {
  2. if (totalCount == Integer.MIN_VALUE) {
  3. if (query == null) {
  4. totalCount = 0;
  5. } else {
  6. Query newQuery = (Query)query.clone();
  7. newQuery.projections().count();
  8. Number result = (Number) newQuery.singleResult();
  9. totalCount = result == null ? 0 : result.intValue();
  10. }
  11. }
  12. }

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

  1. /**
  2. * Defines and executes a list distinct query in a single call. Example: Foo.createCriteria.listDistinct { }
  3. * @param callable The closure to execute
  4. *
  5. * @return The result list
  6. */
  7. public List listDistinct(Closure callable) {
  8. ensureQueryIsInitialized();
  9. invokeClosureNode(callable);
  10. query.projections().distinct();
  11. return query.list();
  12. }

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

  1. public Object doInSession(final Session session) {
  2. Query q = session.createQuery(clazz);
  3. applyAdditionalCriteria(q, additionalCriteria);
  4. boolean ascending = true;
  5. if (arguments.length > 0 && (arguments[0] instanceof Map)) {
  6. final Map args = new LinkedHashMap( (Map) arguments[0] );
  7. final Object order = args.remove(DynamicFinder.ARGUMENT_ORDER);
  8. if(order != null && "desc".equalsIgnoreCase(order.toString())) {
  9. ascending = false;
  10. }
  11. DynamicFinder.populateArgumentsForCriteria(clazz, q, args);
  12. }
  13. q.order( ascending ? Query.Order.asc(propertyName) : Query.Order.desc(propertyName));
  14. q.projections().distinct();
  15. return invokeQuery(q);
  16. }
  17. });

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

  1. /**
  2. * Defines and executes a count query in a single call. Example: Foo.createCriteria.count { }
  3. * @param callable The closure to execute
  4. *
  5. * @return The result count
  6. */
  7. public Number count(Closure callable) {
  8. ensureQueryIsInitialized();
  9. invokeClosureNode(callable);
  10. uniqueResult = true;
  11. query.projections().count();
  12. return (Number) query.singleResult();
  13. }

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

  1. query.projections().add(projection);

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

  1. @Override
  2. public List query(Object primaryKey) {
  3. Association inverseSide = association.getInverseSide();
  4. Query query = session.createQuery(association.getAssociatedEntity().getJavaClass());
  5. query.eq(inverseSide.getName(), primaryKey);
  6. query.projections().id();
  7. return query.list();
  8. }

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

  1. protected Query buildQuery(DynamicFinderInvocation invocation, Class<?> clazz, Query q) {
  2. applyAdditionalCriteria(q, invocation.getCriteria());
  3. configureQueryWithArguments(clazz, q, invocation.getArguments());
  4. String operatorInUse = invocation.getOperator();
  5. if (operatorInUse != null && operatorInUse.equals(OPERATOR_OR)) {
  6. Query.Junction disjunction = q.disjunction();
  7. for (MethodExpression expression : invocation.getExpressions()) {
  8. q.add(disjunction, expression.createCriterion());
  9. }
  10. }
  11. else {
  12. for (MethodExpression expression : invocation.getExpressions()) {
  13. q.add( expression.createCriterion() );
  14. }
  15. }
  16. q.projections().count();
  17. return q;
  18. }
  19. }

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

  1. protected Query buildQuery(DynamicFinderInvocation invocation, Class<?> clazz, Query query) {
  2. applyAdditionalCriteria(query, invocation.getCriteria());
  3. applyDetachedCriteria(query, invocation.getDetachedCriteria());
  4. configureQueryWithArguments(clazz, query, invocation.getArguments());
  5. final String operatorInUse = invocation.getOperator();
  6. if (operatorInUse != null && operatorInUse.equals(OPERATOR_OR)) {
  7. if (firstExpressionIsRequiredBoolean()) {
  8. MethodExpression expression = invocation.getExpressions().remove(0);
  9. query.add(expression.createCriterion());
  10. }
  11. Query.Junction disjunction = query.disjunction();
  12. for (MethodExpression expression : invocation.getExpressions()) {
  13. query.add(disjunction, expression.createCriterion());
  14. }
  15. }
  16. else {
  17. for (MethodExpression expression : invocation.getExpressions()) {
  18. query.add( expression.createCriterion() );
  19. }
  20. }
  21. query.projections().distinct();
  22. return query;
  23. }
  24. }

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

  1. .projections().id();

相关文章