本文整理汇总了Java中com.mysema.query.jpa.impl.JPAQuery.orderBy方法的典型用法代码示例。如果您正苦于以下问题:Java JPAQuery.orderBy方法的具体用法?Java JPAQuery.orderBy怎么用?Java JPAQuery.orderBy使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.mysema.query.jpa.impl.JPAQuery
的用法示例。
在下文中一共展示了JPAQuery.orderBy方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: applyQueryAndFiltersAndSorting
import com.mysema.query.jpa.impl.JPAQuery; //导入方法依赖的package包/类
protected void applyQueryAndFiltersAndSorting(ComputerToCurrentUserDesktopSessionGridSearchState searchState) {
QComputer $record = searchState.$record;
ComputerToCurrentUserDesktopSessionGridSearchParam searchParam = searchState.searchParam;
JPAQuery jpaQuery = searchState.jpaQuery;
// Applying filter
ComputerToCurrentUserDesktopSessionGridSearchFilter filter = searchParam.filter;
if (StringUtils.isNotEmpty(filter.name)) {
jpaQuery.where($record.name.containsIgnoreCase(filter.name));
}
// Applying action filters
// Applying sorting
Sorting sorting = searchParam.sorting;
ComparableExpressionBase sortingExpression = null;
if (sorting != null) {
if ("name".equals(sorting.ref)) {
sortingExpression = $record.name;
}
}
if (sortingExpression != null) {
jpaQuery.orderBy(SortingType.ASCENDING.equals(sorting.type) ? sortingExpression.asc() : sortingExpression.desc());
}
applyPaginationSort(searchState);
}
示例2: applyQueryAndFiltersAndSorting
import com.mysema.query.jpa.impl.JPAQuery; //导入方法依赖的package包/类
protected void applyQueryAndFiltersAndSorting(SpecificSearchUserGridSearchState searchState) {
QUser $record = searchState.$record;
SpecificSearchUserGridSearchParam searchParam = searchState.searchParam;
JPAQuery jpaQuery = searchState.jpaQuery;
// Applying filter
SpecificSearchUserGridSearchFilter filter = searchParam.filter;
if (StringUtils.isNotEmpty(filter.name)) {
jpaQuery.where($record.name.containsIgnoreCase(filter.name));
}
if (StringUtils.isNotEmpty(filter.firstName)) {
jpaQuery.where($record.firstName.containsIgnoreCase(filter.firstName));
}
// Applying action filters
// Applying sorting
Sorting sorting = searchParam.sorting;
ComparableExpressionBase sortingExpression = null;
if (sorting != null) {
if ("name".equals(sorting.ref)) {
sortingExpression = $record.name;
}
}
if (sortingExpression != null) {
jpaQuery.orderBy(SortingType.ASCENDING.equals(sorting.type) ? sortingExpression.asc() : sortingExpression.desc());
}
applyPaginationSort(searchState);
}
示例3: iterator
import com.mysema.query.jpa.impl.JPAQuery; //导入方法依赖的package包/类
@Override
public Iterator<? extends AbstractTask> iterator(long first, long count) {
QAbstractTask task = QAbstractTask.abstractTask;
QWork work = task.as(QWork.class);
JPAQuery query = new JPAQuery(page.getEntityManager());
query.from(QAbstractTask.abstractTask).leftJoin(work.part.project);
query.where(createPredicate());
query.orderBy(task.date.asc());
query.offset(first);
query.limit(count);
List<AbstractTask> found = query.list(task);
if (found != null) {
return found.iterator();
}
return new ArrayList<AbstractTask>().iterator();
}
示例4: listProjectsFromDb
import com.mysema.query.jpa.impl.JPAQuery; //导入方法依赖的package包/类
private static List<CustomerProjectPartDto> listProjectsFromDb(EntityManager entityManager) {
QCustomer customer = QCustomer.customer;
QProject project = QProject.project;
QPart part = QPart.part;
JPAQuery query = new JPAQuery(entityManager);
query.from(customer).leftJoin(customer.projects, project).leftJoin(QProject.project.parts, part);
query.where(QProject.project.closed.eq(false).and(part.id.isNotNull()));
query.orderBy(customer.name.asc(), project.name.asc(), part.name.asc());
Map<String, Expression<?>> bindings = new HashMap<>();
bindings.put(CustomerProjectPartDto.F_CUSTOMER_ID, customer.id);
bindings.put(CustomerProjectPartDto.F_CUSTOMER_NAME, customer.name);
bindings.put(CustomerProjectPartDto.F_PROJECT_ID, project.id);
bindings.put(CustomerProjectPartDto.F_PROJECT_NAME, project.name);
bindings.put(CustomerProjectPartDto.F_PART_ID, part.id);
bindings.put(CustomerProjectPartDto.F_PART_NAME, part.name);
QBean projection = new QBean(CustomerProjectPartDto.class, true, bindings);
return query.list(projection);
}
示例5: loadData
import com.mysema.query.jpa.impl.JPAQuery; //导入方法依赖的package包/类
public static List<AbstractTask> loadData(WorkFilterDto filter, EntityManager entityManager) {
List<AbstractTask> data = new ArrayList<>();
if (filter == null) {
return data;
}
List<Predicate> predicates = AbstractTaskDataProvider.createPredicates(filter);
QAbstractTask task = QAbstractTask.abstractTask;
QWork work = task.as(QWork.class);
JPAQuery query = new JPAQuery(entityManager);
query.from(task).leftJoin(work.part.project);
if (!predicates.isEmpty()) {
BooleanBuilder where = new BooleanBuilder();
where.orAllOf(predicates.toArray(new Predicate[predicates.size()]));
query.where(where);
}
query.orderBy(task.date.asc());
return query.list(task);
}
示例6: parse
import com.mysema.query.jpa.impl.JPAQuery; //导入方法依赖的package包/类
public JPAQuery parse(String expression, QueryDslContext context, ParserConfig config) {
QueryDslEvaluator evaluator = new QueryDslEvaluator();
evaluator.evaluate(expression, context, config);
JPAQuery query = new JPAQuery(em)
.from(context.getEntityPath());
if (context.getPredicate() != null) {
query.where(context.getPredicate());
}
if (context.getQueryModifiers() != null) {
query.restrict(context.getQueryModifiers());
}
if (context.getOrderSpecifiers() != null && !context.getOrderSpecifiers().isEmpty()) {
query.orderBy(context.getOrderSpecifiers().toArray(new OrderSpecifier[0]));
}
return query;
}
示例7: applyPaging
import com.mysema.query.jpa.impl.JPAQuery; //导入方法依赖的package包/类
private <T, R> void applyPaging(JoinerQuery<T, R> request, JPAQuery query) {
if (request.getLimit() != null) {
query.limit(request.getLimit());
}
if (request.getOffset() != null) {
query.offset(request.getOffset());
}
for (QueryOrder queryOrder : request.getOrder()) {
// TODO apply predicate resolver as well
query.orderBy(transformOrder(queryOrder));
}
}
示例8: applyQueryAndFiltersAndSorting
import com.mysema.query.jpa.impl.JPAQuery; //导入方法依赖的package包/类
protected void applyQueryAndFiltersAndSorting(ProfileGridSearchState searchState) {
QProfile $record = searchState.$record;
ProfileGridSearchParam searchParam = searchState.searchParam;
JPAQuery jpaQuery = searchState.jpaQuery;
// Applying filter
ProfileGridSearchFilter filter = searchParam.filter;
if (StringUtils.isNotEmpty(filter.name)) {
jpaQuery.where($record.name.containsIgnoreCase(filter.name));
}
// Applying action filters
if (filter.openProfileGridFromUser != null) {
// Check additionnal rights for that action
securityService.check("admin");
OpenProfileGridFromUser parameters = filter.openProfileGridFromUser;
jpaQuery.where($record.id.eq(parameters.profileId));
}
// Applying sorting
Sorting sorting = searchParam.sorting;
ComparableExpressionBase sortingExpression = null;
if (sorting != null) {
if ("name".equals(sorting.ref)) {
sortingExpression = $record.name;
}
}
if (sortingExpression != null) {
jpaQuery.orderBy(SortingType.ASCENDING.equals(sorting.type) ? sortingExpression.asc() : sortingExpression.desc());
}
applyPaginationSort(searchState);
}
示例9: getPaginatedResult
import com.mysema.query.jpa.impl.JPAQuery; //导入方法依赖的package包/类
@Override
public Page<Tuple> getPaginatedResult(QueryParameters parameters, JPAQuery jpaQuery, Expression<?>... args) {
Optional<OrderSpecifier> orderSpecifier = getOrderSpecifier(parameters, args);
if (orderSpecifier.isPresent()) {
jpaQuery.orderBy(orderSpecifier.get());
}
List<Tuple> result = jpaQuery.offset(parameters.getDisplayStart()).limit(parameters.getSize()).list(args);
return new PageImpl<>(result, pageableFactory.getPageable(parameters), jpaQuery.count());
}