本文整理汇总了Java中com.mysema.query.jpa.impl.JPAQuery类的典型用法代码示例。如果您正苦于以下问题:Java JPAQuery类的具体用法?Java JPAQuery怎么用?Java JPAQuery使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
JPAQuery类属于com.mysema.query.jpa.impl包,在下文中一共展示了JPAQuery类的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: findUnreportedWarrentys
import com.mysema.query.jpa.impl.JPAQuery; //导入依赖的package包/类
/**
* This Method returns all unreported Warranties.
* <p>
* @return all unreported warranties.
*/
public List<ReportLine> findUnreportedWarrentys() {
// This works in mysql, but fails in hsqldb.
// return new JPAQuery(em).from(reportLine)
// .where(reportLine.positionType.eq(PRODUCT_BATCH),
// reportLine.singleReferences.containsKey(WARRANTY),
// reportLine.reports.isEmpty()).list(reportLine);
return new JPAQuery(em)
.from(reportLine)
.where(reportLine.positionType.eq(PRODUCT_BATCH),
reportLine.reports.isEmpty())
.list(reportLine)
.stream()
.filter(l -> l.getReference(WARRANTY) != null)
.collect(Collectors.toList());
}
示例5: 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();
}
示例6: 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;
}
示例7: 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;
}
示例8: 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);
}
示例9: 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);
}
示例10: findAllTest
import com.mysema.query.jpa.impl.JPAQuery; //导入依赖的package包/类
@Test
public void findAllTest() {
Employee emp = new Employee();
emp.setName("Sunghyouk Bae");
emp.setEmpNo("21011");
emp = employeeRepository.save(emp);
QEmployee $ = QEmployee.employee;
JPAQuery query = new JPAQuery(em);
Employee loaded = query.from($)
.where($.empNo.eq("21011"))
.uniqueResult($);
assertThat(loaded).isNotNull();
assertThat(loaded.getEmpNo()).isEqualTo(emp.getEmpNo());
assertThat(loaded).isEqualTo(emp);
assertThat(loaded.isPersisted()).isTrue();
}
示例11: checkCreditNote
import com.mysema.query.jpa.impl.JPAQuery; //导入依赖的package包/类
@Override
public PTCreditNoteEntity checkCreditNote(PTInvoice invoice) {
QJPAPTCreditNoteEntity creditNoteEntity = QJPAPTCreditNoteEntity.jPAPTCreditNoteEntity;
JPAQuery query = new JPAQuery(this.getEntityManager());
query.from(creditNoteEntity);
List<JPAPTCreditNoteEntity> allCns = query.list(creditNoteEntity);
// TODO make a query to do this
for (JPAPTCreditNoteEntity cne : allCns) {
for (PTCreditNoteEntry cnee : cne.getEntries()) {
if (cnee.getReference().getNumber().compareTo(invoice.getNumber()) == 0) {
return cne;
}
}
}
return null;
}
示例12: checkCreditNote
import com.mysema.query.jpa.impl.JPAQuery; //导入依赖的package包/类
@Override
public ESCreditNoteEntity checkCreditNote(ESInvoice invoice) {
QJPAESCreditNoteEntity creditNoteEntity = QJPAESCreditNoteEntity.jPAESCreditNoteEntity;
JPAQuery query = new JPAQuery(this.getEntityManager());
query.from(creditNoteEntity);
List<JPAESCreditNoteEntity> allCns = query.list(creditNoteEntity);
// TODO make a query to do this
for (JPAESCreditNoteEntity cne : allCns) {
for (ESCreditNoteEntry cnee : cne.getEntries()) {
if (cnee.getReference().getNumber().compareTo(invoice.getNumber()) == 0) {
return cne;
}
}
}
return null;
}
示例13: checkCreditReceipt
import com.mysema.query.jpa.impl.JPAQuery; //导入依赖的package包/类
@Override
public ESCreditReceiptEntity checkCreditReceipt(ESReceipt receipt) {
QJPAESCreditReceiptEntity creditReceiptEntity = QJPAESCreditReceiptEntity.jPAESCreditReceiptEntity;
JPAQuery query = new JPAQuery(this.getEntityManager());
query.from(creditReceiptEntity);
List<JPAESCreditReceiptEntity> allCns = query.list(creditReceiptEntity);
// TODO make a query to do this
for (JPAESCreditReceiptEntity cne : allCns) {
for (ESCreditReceiptEntry cnee : cne.getEntries()) {
if (cnee.getReference().getNumber().compareTo(receipt.getNumber()) == 0) {
return cne;
}
}
}
return null;
}
示例14: checkCreditNote
import com.mysema.query.jpa.impl.JPAQuery; //导入依赖的package包/类
@Override
public FRCreditNoteEntity checkCreditNote(FRInvoice invoice) {
QJPAFRCreditNoteEntity creditNoteEntity = QJPAFRCreditNoteEntity.jPAFRCreditNoteEntity;
JPAQuery query = new JPAQuery(this.getEntityManager());
query.from(creditNoteEntity);
List<JPAFRCreditNoteEntity> allCns = query.list(creditNoteEntity);
// TODO make a query to do this
for (JPAFRCreditNoteEntity cne : allCns) {
for (FRCreditNoteEntry cnee : cne.getEntries()) {
if (cnee.getReference().getNumber().compareTo(invoice.getNumber()) == 0) {
return cne;
}
}
}
return null;
}
示例15: checkCreditReceipt
import com.mysema.query.jpa.impl.JPAQuery; //导入依赖的package包/类
@Override
public FRCreditReceiptEntity checkCreditReceipt(FRReceipt receipt) {
QJPAFRCreditReceiptEntity creditReceiptEntity = QJPAFRCreditReceiptEntity.jPAFRCreditReceiptEntity;
JPAQuery query = new JPAQuery(this.getEntityManager());
query.from(creditReceiptEntity);
List<JPAFRCreditReceiptEntity> allCns = query.list(creditReceiptEntity);
// TODO make a query to do this
for (JPAFRCreditReceiptEntity cne : allCns) {
for (FRCreditReceiptEntry cnee : cne.getEntries()) {
if (cnee.getReference().getNumber().compareTo(receipt.getNumber()) == 0) {
return cne;
}
}
}
return null;
}