本文整理汇总了Java中com.mysema.query.jpa.impl.JPAQuery.where方法的典型用法代码示例。如果您正苦于以下问题:Java JPAQuery.where方法的具体用法?Java JPAQuery.where怎么用?Java JPAQuery.where使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.mysema.query.jpa.impl.JPAQuery
的用法示例。
在下文中一共展示了JPAQuery.where方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: applyPredicates
import com.mysema.query.jpa.impl.JPAQuery; //导入方法依赖的package包/类
/**
* Apply "where", "groupBy" and "having"
*
* @param request
* @param query
* @param usedAliases
* @param joins
* @param <T>
* @param <R>
*/
private <T, R> void applyPredicates(JoinerQuery<T, R> request, JPAQuery query, Set<Path<?>> usedAliases, List<JoinDescription> joins) {
if (request.getWhere() != null) {
Predicate where = predicateAliasResolver.resolvePredicate(request.getWhere(), joins, usedAliases);
checkAliasesArePresent(where, usedAliases);
query.where(where);
}
if (request.getGroupBy() != null) {
Map<AnnotatedElement, List<JoinDescription>> grouped = joins.stream()
.collect(Collectors.groupingBy(j -> j.getOriginalAlias().getAnnotatedElement()));
Path<?> grouping = predicateAliasResolver.resolvePath(request.getGroupBy(), grouped, usedAliases);
checkAliasesArePresent(grouping, usedAliases);
query.groupBy(grouping);
}
if (request.getHaving() != null) {
Predicate having = predicateAliasResolver.resolvePredicate(request.getHaving(), joins, usedAliases);
checkAliasesArePresent(having, usedAliases);
query.having(having);
}
}
示例2: 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);
}
示例3: 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);
}
示例4: 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();
}
示例5: getCustomers
import com.mysema.query.jpa.impl.JPAQuery; //导入方法依赖的package包/类
private Map<Integer, Customer> getCustomers(List<Integer> ids) {
Map<Integer, Customer> map = new HashMap<>();
if (ids.isEmpty()) {
return map;
}
QCustomer customer = QCustomer.customer;
JPAQuery query = new JPAQuery(page.getEntityManager());
query.from(customer);
query.where(customer.id.in(ids));
List<Customer> customers = query.list(customer);
if (customers == null) {
return map;
}
for (Customer c : customers) {
map.put(c.getId(), c);
}
return map;
}
示例6: getProjectParts
import com.mysema.query.jpa.impl.JPAQuery; //导入方法依赖的package包/类
private Map<Integer, Part> getProjectParts(List<Integer> ids) {
Map<Integer, Part> map = new HashMap<>();
if (ids.isEmpty()) {
return map;
}
QPart part = QPart.part;
JPAQuery query = new JPAQuery(page.getEntityManager());
query.from(part);
query.where(part.id.in(ids));
List<Part> parts = query.list(part);
if (parts == null) {
return map;
}
for (Part p : parts) {
map.put(p.getId(), p);
}
return map;
}
示例7: 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);
}
示例8: 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);
}
示例9: 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;
}
示例10: 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);
}
示例11: filterByProperties
import com.mysema.query.jpa.impl.JPAQuery; //导入方法依赖的package包/类
private JPAQuery filterByProperties(FlowInstanceSelector instanceSelector, JPAQuery instanceQuery) {
for (EqualsExpression<Property<?>, Value<String>> propertyExpression : instanceSelector.properties()) {
QInstancePropertyEntity instanceProperty = QFlowInstanceEntity
.flowInstanceEntity
.properties.any();
instanceQuery
.where(instanceProperty.stringValue.eq(propertyExpression.getRight().getValue())
.and(instanceProperty.propertyKey.eq(propertyExpression.getLeft().getValue().stringValue())));
}
return instanceQuery;
}
示例12: filterByDefinitionId
import com.mysema.query.jpa.impl.JPAQuery; //导入方法依赖的package包/类
private JPAQuery filterByDefinitionId(FlowInstanceSelector instanceSelector, JPAQuery instanceQuery) {
if (instanceSelector.definitionId().isPresent()) {
BooleanExpression matchesDefinitionId = QFlowInstanceEntity
.flowInstanceEntity
.definitionId
.eq(instanceSelector.definitionId().get().stringValue());
return instanceQuery.where(matchesDefinitionId);
}
return instanceQuery;
}
示例13: filterByInstance
import com.mysema.query.jpa.impl.JPAQuery; //导入方法依赖的package包/类
private JPAQuery filterByInstance(FlowInstanceSelector instanceSelector, JPAQuery instanceQuery) {
if (instanceSelector.instanceId().isPresent()) {
BooleanExpression matchesInstanceId = QFlowInstanceEntity
.flowInstanceEntity
.id
.eq(instanceSelector.instanceId().get().stringValue());
return instanceQuery.where(matchesInstanceId);
}
return instanceQuery;
}
示例14: queryWithOptionalDueDate
import com.mysema.query.jpa.impl.JPAQuery; //导入方法依赖的package包/类
JPAQuery queryWithOptionalDueDate(JPAQuery jpaQuery, AsyncTriggerQuery taskQuery) {
if (taskQuery.getOverdueDate().isPresent()) {
long dueDate = taskQuery.getOverdueDate().get().getTime();
return jpaQuery
.where(QAsyncTaskEntity.asyncTaskEntity.dueDate.loe(dueDate));
}
return jpaQuery;
}
示例15: createSummary
import com.mysema.query.jpa.impl.JPAQuery; //导入方法依赖的package包/类
/**
* select date_trunc('day' ,date), sum(length), sum(invoice) from tasks
* where realizator_id=9 and date >= '2014-08-01 00:00:00' and date <= '2014-08-31 23:59:59'
* group by date_trunc('day' ,date) order by date_trunc('day' ,date);
*
* @param filter
* @return
*/
public SummaryPanelDto createSummary(WorkFilterDto filter) {
SummaryPanelDto dto = new SummaryPanelDto(filter);
List<Predicate> list = AbstractTaskDataProvider.createPredicates(filter);
QAbstractTask task = QAbstractTask.abstractTask;
QWork work = task.as(QWork.class);
JPAQuery query = new JPAQuery(page.getEntityManager());
query.from(task).leftJoin(work.part.project);
if (!list.isEmpty()) {
BooleanBuilder bb = new BooleanBuilder();
bb.orAllOf(list.toArray(new Predicate[list.size()]));
query.where(bb);
}
query.groupBy(createDateTruncExpression(work));
List<Tuple> tuples = query.list(createDateTruncExpression(work),
task.workLength.sum(), work.invoiceLength.sum());
if (tuples != null) {
for (Tuple tuple : tuples) {
TaskLength taskLength = new TaskLength(tuple.get(1, Double.class), tuple.get(2, Double.class));
dto.getDates().put(tuple.get(0, Date.class), taskLength);
}
}
return dto;
}