本文整理了Java中javax.persistence.criteria.Order
类的一些代码示例,展示了Order
类的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Order
类的具体详情如下:
包路径:javax.persistence.criteria.Order
类名称:Order
[英]An object that defines an ordering over the query results.
[中]定义查询结果排序的对象。
代码示例来源: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: org.aksw.jena-sparql-api/jena-sparql-api-mapper
Expr e = x.accept(orderCompiler);
int dir = order.isAscending() ? Query.ORDER_ASCENDING : Query.ORDER_DESCENDING;
sortConditions.add(new SortCondition(e, dir));
代码示例来源:origin: katharsis-project/katharsis-framework
@Override
public Expression<?> getExpression(Order order) {
return order.getExpression();
}
代码示例来源:origin: SmartDataAnalytics/jena-sparql-api
Expr e = x.accept(orderCompiler);
int dir = order.isAscending() ? Query.ORDER_ASCENDING : Query.ORDER_DESCENDING;
sortConditions.add(new SortCondition(e, dir));
代码示例来源:origin: babyfish-ct/babyfish
@Override
public void visitOrder(Order order) {
this.visit(order.getExpression());
this.jpqlBuilder.append(order.isAscending() ? " asc" : " desc");
}
代码示例来源:origin: babyfish-ct/babyfish
@Override
public void visitOrder(Order order) {
this.visit(order.getExpression());
}
代码示例来源: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: 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: 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: 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
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
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: 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();
}
内容来源于网络,如有侵权,请联系作者删除!