• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java Order类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中com.querydsl.core.types.Order的典型用法代码示例。如果您正苦于以下问题:Java Order类的具体用法?Java Order怎么用?Java Order使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



Order类属于com.querydsl.core.types包,在下文中一共展示了Order类的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: sortToOrderSpecifier_Ascending

import com.querydsl.core.types.Order; //导入依赖的package包/类
@Test
public void sortToOrderSpecifier_Ascending() {
    String sortExpression = "sort(+employeeNumber)";
    DefaultSortParser sortParser = new DefaultSortParser();
    Map<String, Path> mappings = ImmutableMap.<String, Path>builder()
            .put("employeeNumber", QEmployee.employee.employeeNumber)
            .build();

    OrderSpecifierList orderSpecifierList = sortParser.parse(sortExpression, QuerydslSortContext.withMapping(mappings));
    assertNotNull(orderSpecifierList);

    List<OrderSpecifier> orderSpecifiers = orderSpecifierList.getOrders();
    assertNotNull(orderSpecifiers);
    assertEquals(1, orderSpecifiers.size());
    OrderSpecifier orderSpecifier = orderSpecifiers.get(0);
    assertEquals(Order.ASC, orderSpecifier.getOrder());
    assertEquals(QEmployee.employee.employeeNumber, orderSpecifier.getTarget());
}
 
开发者ID:vineey,项目名称:archelix-rsql,代码行数:19,代码来源:QuerydslSortContextTest.java


示例2: sortToOrderSpecifier_Descending

import com.querydsl.core.types.Order; //导入依赖的package包/类
@Test
public void sortToOrderSpecifier_Descending() {

    String sortExpression = "sort(-employee.id)";
    DefaultSortParser sortParser = new DefaultSortParser();
    Map<String, Path> mappings = ImmutableMap.<String, Path>builder()
            .put("employee.id", QEmployee.employee.employeeNumber)
            .build();

    OrderSpecifierList orderSpecifierList = sortParser.parse(sortExpression, QuerydslSortContext.withMapping(mappings));
    assertNotNull(orderSpecifierList);

    List<OrderSpecifier> orderSpecifiers = orderSpecifierList.getOrders();
    assertNotNull(orderSpecifiers);
    assertEquals(1, orderSpecifiers.size());
    OrderSpecifier orderSpecifier = orderSpecifiers.get(0);
    assertEquals(Order.DESC, orderSpecifier.getOrder());
    assertEquals(QEmployee.employee.employeeNumber, orderSpecifier.getTarget());
}
 
开发者ID:vineey,项目名称:archelix-rsql,代码行数:20,代码来源:QuerydslSortContextTest.java


示例3: newSort

import com.querydsl.core.types.Order; //导入依赖的package包/类
@Override
public OrderSpecifier<?> newSort(Expression<?> expr, Direction dir) {
	if (dir == Direction.ASC) {
		return new OrderSpecifier(Order.ASC, expr);
	}
	else {
		return new OrderSpecifier(Order.DESC, expr);
	}
}
 
开发者ID:katharsis-project,项目名称:katharsis-framework,代码行数:10,代码来源:QuerydslQueryBackend.java


示例4: appendOrder

import com.querydsl.core.types.Order; //导入依赖的package包/类
private void appendOrder() {
    if (quickFilter.getSortProperty() != null) {
        Order order = quickFilter.isAscending() ? Order.ASC : Order.DESC;
        query.orderBy(new OrderSpecifier<>(order, Expressions.stringPath(quickFilter.getSortProperty())));
    } else if (!Boolean.TRUE.equals(ctx.getCount())) {
        if (quickFilter.isRascunho()) {
            query.orderBy(new OrderSpecifier<>(Order.ASC, Expressions.stringPath("creationDate")));
        } else {
            query.orderBy(new OrderSpecifier<>(Order.ASC, Expressions.stringPath("processBeginDate")));
        }
    }
}
 
开发者ID:opensingular,项目名称:singular-server,代码行数:13,代码来源:RequirementSearchQueryFactory.java


示例5: visit

import com.querydsl.core.types.Order; //导入依赖的package包/类
@Override
public OrderSpecifierList visit(SortNodeList node, QuerydslSortParam filterParam) {
    List<SortNode> sortNodes = node.getNodes();

    List<OrderSpecifier> orderSpecifiers = new ArrayList<>();
    Map<String, Path> mapping = filterParam.getMapping();
    for(SortNode sortNode : sortNodes){
        Order order = SortNode.Order.DESC.equals(sortNode.getOrder()) ? Order.DESC : Order.ASC;
        Path path = mapping.get(sortNode.getField());
        OrderSpecifier orderSpecifier = new OrderSpecifier(order, path);
        orderSpecifiers.add(orderSpecifier);
    }
    return new OrderSpecifierList(orderSpecifiers);
}
 
开发者ID:vineey,项目名称:archelix-rsql,代码行数:15,代码来源:QuerydslSortBuilder.java


示例6: createOrderSpecifiers

import com.querydsl.core.types.Order; //导入依赖的package包/类
@SuppressWarnings({ "rawtypes", "unchecked" })
public static OrderSpecifier[] createOrderSpecifiers(
		ExtDirectStoreReadRequest request, Class<?> clazz,
		EntityPathBase<?> entityPathBase, Map<String, String> mapGuiColumn2Dbfield,
		Set<String> sortIgnoreProperties) {

	List<OrderSpecifier> orders;

	if (!request.getSorters().isEmpty()) {
		orders = new ArrayList<>();
		PathBuilder<?> entityPath = new PathBuilder<>(clazz,
				entityPathBase.getMetadata());
		for (SortInfo sortInfo : request.getSorters()) {

			if (!sortIgnoreProperties.contains(sortInfo.getProperty())) {
				Order order;
				if (sortInfo.getDirection() == SortDirection.ASCENDING) {
					order = Order.ASC;
				}
				else {
					order = Order.DESC;
				}

				String property = mapGuiColumn2Dbfield.get(sortInfo.getProperty());
				if (property == null) {
					property = sortInfo.getProperty();
				}

				orders.add(new OrderSpecifier(order, entityPath.get(property)));
			}
		}

	}
	else {
		orders = Collections.emptyList();
	}

	return orders.toArray(new OrderSpecifier[orders.size()]);
}
 
开发者ID:ralscha,项目名称:eds-starter6-jpa,代码行数:40,代码来源:QuerydslUtil.java


示例7: lockEntitiesForUpdate

import com.querydsl.core.types.Order; //导入依赖的package包/类
protected Map<Id, Long> lockEntitiesForUpdate(EntityStoreOptions<Id, M, V> options, Collection<Id> docIds) {
    return options.queryFactory
            .from(options.entity)
            .where(predicate(IN, options.entity.id, constant(docIds)))
            .orderBy(new OrderSpecifier<>(Order.ASC, options.entity.id))
            .forUpdate()
            .transform(groupBy(options.entity.id).as(maxLocalOrdinalByEntity(options)));
}
 
开发者ID:ssaarela,项目名称:javersion,代码行数:9,代码来源:EntityUpdateBatch.java


示例8: applyPagination

import com.querydsl.core.types.Order; //导入依赖的package包/类
/**
 * Applies the given {@link Pageable} to the given {@link JPQLQuery}.
 * Allows to map the attributes to order as provided in the {@link Pageable}
 * to real entity attributes. This might be used to work with projections
 * or DTOs whose attributes don't have the same name as the entity ones.
 *
 * It allows to map to more than one entity attribute. As an example, if
 * the DTO used to create the {@link Pageable} has a fullName attribute, you
 * could map that attribute to two entity attributes: name and surname.
 * In this case, the {@link Pageable} defines an order by a fullName
 * attribute, but que query will order by name and surname instead.
 *
 * @param pageable the ordering and paging
 * @param query
 * @param attributeMapping definition of a mapping of order attribute names
 *        to real entity ones
 * @return the updated query
 */
protected JPQLQuery<T> applyPagination(Pageable pageable, JPQLQuery<T> query,
    Map<String, Path<?>[]> attributeMapping) {

  if (pageable == null) {
    return query;
  }

  Pageable mappedPageable;
  Sort sort = pageable.getSort();
  if (sort != null) {
    List<Sort.Order> mappedOrders = new ArrayList<Sort.Order>();
    for (Sort.Order order : sort) {
      if (!attributeMapping.containsKey(order.getProperty())) {
        LOG.warn(
            "The property (%1) is not included in the attributeMapping, will order "
                + "using the property as it is",
            order.getProperty());
        mappedOrders.add(order);
      } else {
        Path<?>[] paths = attributeMapping.get(order.getProperty());
        for (Path<?> path : paths) {
          Sort.Order mappedOrder =
              new Sort.Order(order.getDirection(), preparePropertyPath(path));
          mappedOrders.add(mappedOrder);
        }
      }
    }
    if (mappedOrders.isEmpty()) {
      // No properties to order by are available, so don't apply ordering and return the query
      // as it is
      return query;
    }
    mappedPageable =
        new PageRequest(pageable.getPageNumber(), pageable.getPageSize(), new Sort(mappedOrders));
    return applyPagination(mappedPageable, query);
  } else {
    return applyPagination(pageable, query);
  }

}
 
开发者ID:DISID,项目名称:springlets,代码行数:59,代码来源:QueryDslRepositorySupportExt.java


示例9: applyOrderById

import com.querydsl.core.types.Order; //导入依赖的package包/类
/**
 * Adds to a query an order by the entity identifier related to this repository.
 * This is useful as the default last order in queries where pagination is
 * applied, so you have always an absolute order. Otherwise, the order
 * of the results depends on the database criteria, which might change
 * even between pages, returning confusing results for the user.
 * @param query
 * @return the updated query
 */
@SuppressWarnings({"rawtypes", "unchecked"})
protected JPQLQuery<T> applyOrderById(JPQLQuery<T> query) {
  PathBuilder<Object> idPath = getEntityId();

  return query.orderBy(new OrderSpecifier(Order.ASC, idPath, NullHandling.NullsFirst));
}
 
开发者ID:DISID,项目名称:springlets,代码行数:16,代码来源:QueryDslRepositorySupportExt.java



注:本文中的com.querydsl.core.types.Order类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java DN类代码示例发布时间:2022-05-22
下一篇:
Java Constants类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap