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

x33g5p2x  于2022-01-26 转载在 其他  
字(7.0k)|赞(0)|评价(0)|浏览(163)

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

Order.getExpression介绍

[英]Return the expression that is used for ordering.
[中]返回用于排序的表达式。

代码示例

代码示例来源:origin: hibernate/hibernate-orm

protected void renderOrderByClause(RenderingContext renderingContext, StringBuilder jpaqlBuffer) {
    if ( getOrderList().isEmpty() ) {
      return;
    }

    renderingContext.getClauseStack().push( Clause.ORDER );
    try {
      jpaqlBuffer.append( " order by " );
      String sep = "";
      for ( Order orderSpec : getOrderList() ) {
        jpaqlBuffer.append( sep )
            .append( ( (Renderable) orderSpec.getExpression() ).render( renderingContext ) )
            .append( orderSpec.isAscending() ? " asc" : " desc" );
        sep = ", ";
      }
    }
    finally {
      renderingContext.getClauseStack().pop();
    }
  }
}

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

QueryBuilder appendOrdering(Order orderAttribute)
{
  DefaultPath expression = (DefaultPath) orderAttribute.getExpression();
  Attribute attrib = expression.getAttribute();
  Attribute embedAttribute = expression.getEmbeddedAttribute();
  String fieldName = null;
  this.builder.append(".");
  if (embedAttribute != null)
  {
    fieldName = embedAttribute.getName();
    this.builder.append(fieldName);
    this.builder.append(".");
  }
  this.builder.append(attrib.getName());
  SortOrder order = ((QueryOrder) orderAttribute).getOrder();
  this.builder.append(Constants.SPACE);
  this.builder.append(order.name());
  return this;
}

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

@Override
public Expression<?> getExpression(Order order) {
  return order.getExpression();
}

代码示例来源:origin: babyfish-ct/babyfish

@Override
public void visitOrder(Order order) {
  this.visit(order.getExpression());
}

代码示例来源:origin: babyfish-ct/babyfish

@Override
public void visitOrder(Order order) {
  this.visit(order.getExpression());
  this.jpqlBuilder.append(order.isAscending() ? " asc" : " desc");
}

代码示例来源:origin: stackoverflow.com

// Call the original method to convert the orders
List<Order> orders = QueryUtils.toOrders(sort, root, builder);
for (Order order : orders) {
 // Fetch the original order object from the sort for comparing
 SingularAttributePath orderExpression = (SingularAttributePath) order.getExpression();
 Sort.Order originalOrder = sort.getOrderFor(orderExpression.getAttribute().getName());
 // Check if the original order object is instantiated from my custom order class
 // Also check if the the order should be natural
 if (originalOrder instanceof NaturalSort.NaturalOrderm && ((NaturalSort.NaturalOrder) originalOrder).isNatural()){
  // replace the order with the custom class
  Order newOrder = new OrderImpl(new NaturalSingularAttributePathImpl(builder, expression.getJavaType(), expression.getPathSource(), expression.getAttribute()));
  resultList.add(newOrder);
 }else{
  resultList.add(order);
 }
}
return resultList;

代码示例来源:origin: org.hibernate/com.springsource.org.hibernate.ejb

for ( Order orderSpec : getOrderList() ) {
  jpaqlQuery.append( sep )
      .append( ( ( Renderable ) orderSpec.getExpression() ).render( renderingContext ) )
      .append( orderSpec.isAscending() ? " asc" : " desc" );
  sep = ", ";

代码示例来源:origin: Blazebit/blaze-persistence

private void renderOrderBy(OrderByBuilder<?> ob, RenderContextImpl context) {
  if (orderList == null) {
    return;
  }
  context.setClauseType(ClauseType.ORDER_BY);
  for (Order order : orderList) {
    context.getBuffer().setLength(0);
    ((AbstractSelection<?>) order.getExpression()).render(context);
    String expression = context.takeBuffer();
    Map<String, InternalQuery<?>> aliasToSubqueries = context.takeAliasToSubqueryMap();
    if (aliasToSubqueries.isEmpty()) {
      boolean nullsFirst = false;
      if (order instanceof BlazeOrder) {
        nullsFirst = ((BlazeOrder) order).isNullsFirst();
      }
      ob.orderBy(expression, order.isAscending(), nullsFirst);
    } else {
      throw new IllegalArgumentException("Subqueries are not supported in the order by clause!");
      //            MultipleSubqueryInitiator<?> initiator = ob.groupBySubqueries(expression);
      //
      //            for (Map.Entry<String, InternalQuery<?>> subqueryEntry : aliasToSubqueries.entrySet()) {
      //                context.pushSubqueryInitiator(initiator.with(subqueryEntry.getKey()));
      //                subqueryEntry.getValue().renderSubquery(context);
      //                context.popSubqueryInitiator();
      //            }
      //
      //            initiator.end();
    }
  }
}

代码示例来源:origin: com.blazebit/blaze-persistence-jpa-criteria-impl

private void renderOrderBy(OrderByBuilder<?> ob, RenderContextImpl context) {
  if (orderList == null) {
    return;
  }
  context.setClauseType(ClauseType.ORDER_BY);
  for (Order order : orderList) {
    context.getBuffer().setLength(0);
    ((AbstractSelection<?>) order.getExpression()).render(context);
    String expression = context.takeBuffer();
    Map<String, InternalQuery<?>> aliasToSubqueries = context.takeAliasToSubqueryMap();
    if (aliasToSubqueries.isEmpty()) {
      boolean nullsFirst = false;
      if (order instanceof BlazeOrder) {
        nullsFirst = ((BlazeOrder) order).isNullsFirst();
      }
      ob.orderBy(expression, order.isAscending(), nullsFirst);
    } else {
      throw new IllegalArgumentException("Subqueries are not supported in the order by clause!");
      //            MultipleSubqueryInitiator<?> initiator = ob.groupBySubqueries(expression);
      //
      //            for (Map.Entry<String, InternalQuery<?>> subqueryEntry : aliasToSubqueries.entrySet()) {
      //                context.pushSubqueryInitiator(initiator.with(subqueryEntry.getKey()));
      //                subqueryEntry.getValue().renderSubquery(context);
      //                context.popSubqueryInitiator();
      //            }
      //
      //            initiator.end();
    }
  }
}

代码示例来源:origin: babyfish-ct/babyfish

@Override
public void visitOrder(Order order) {
  this
  .append("Order")
  .beginMap();
  
  this.append("expression: ").append(order.getExpression()).appendLine(",");
  this.append("ascending: ").append(order.isAscending()).appendLine();
  
  this.endMap();
}

代码示例来源:origin: Blazebit/blaze-persistence

public Set<ParameterExpression<?>> getParameters() {
  // NOTE: we have to always visit them because it's not possible to cache that easily
  ParameterVisitor visitor = new ParameterVisitor();
  visitor.visit(selection);
  visitor.visit(restriction);
  if (subqueries != null) {
    for (Subquery<?> subquery : subqueries) {
      visitor.visit(subquery);
    }
  }
  for (RootImpl<?> r : roots) {
    r.visit(visitor);
  }
  for (AbstractFrom<?, ?> r : correlationRoots) {
    r.visit(visitor);
  }
  visitor.visit(having);
  if (groupList != null) {
    for (Expression<?> grouping : groupList) {
      visitor.visit(grouping);
    }
  }
  if (orderList != null) {
    for (Order ordering : orderList) {
      visitor.visit(ordering.getExpression());
    }
  }
  return visitor.getParameters();
}

代码示例来源:origin: com.blazebit/blaze-persistence-jpa-criteria-impl

public Set<ParameterExpression<?>> getParameters() {
  // NOTE: we have to always visit them because it's not possible to cache that easily
  ParameterVisitor visitor = new ParameterVisitor();
  visitor.visit(selection);
  visitor.visit(restriction);
  if (subqueries != null) {
    for (Subquery<?> subquery : subqueries) {
      visitor.visit(subquery);
    }
  }
  for (RootImpl<?> r : roots) {
    r.visit(visitor);
  }
  for (AbstractFrom<?, ?> r : correlationRoots) {
    r.visit(visitor);
  }
  visitor.visit(having);
  if (groupList != null) {
    for (Expression<?> grouping : groupList) {
      visitor.visit(grouping);
    }
  }
  if (orderList != null) {
    for (Order ordering : orderList) {
      visitor.visit(ordering.getExpression());
    }
  }
  return visitor.getParameters();
}

相关文章