Package com.mysema.query.jpa

Examples of com.mysema.query.jpa.JPQLQuery


    @Override
    public final Page<T> findAll(Predicate predicate, Pageable pageable, List<String> fetchFields) {
        if (fetchFields == null || fetchFields.isEmpty()) {
            return super.findAll(predicate, pageable);
        }
        JPQLQuery fetchQuery = createQuery(predicate);
        for (String fetchField : fetchFields) {
            fetchQuery.leftJoin(builder.get(fetchField)).fetch();
        }
        JPQLQuery query = querydsl.applyPagination(pageable, fetchQuery);

        return new PageImpl<T>(query.list(path), pageable, createQuery(predicate).count());
    }
View Full Code Here


    @Override
    public final Page<T> findAll(Predicate predicate, Pageable pageable, List<String> fetchFields) {
        if (fetchFields == null || fetchFields.isEmpty()) {
            return super.findAll(predicate, pageable);
        }
        JPQLQuery fetchQuery = createQuery(predicate);
        for (String fetchField : fetchFields) {
            fetchQuery.leftJoin(builder.get(fetchField)).fetch();
        }
        JPQLQuery query = querydsl.applyPagination(pageable, fetchQuery);

        return new PageImpl<T>(query.list(path), pageable, createQuery(predicate).count());
    }
View Full Code Here

   * (non-Javadoc)
   * @see org.springframework.data.querydsl.QueryDslPredicateExecutor#findAll(com.mysema.query.types.Predicate, com.mysema.query.types.OrderSpecifier<?>[])
   */
  public List<T> findAll(Predicate predicate, OrderSpecifier<?>... orders) {

    JPQLQuery query = createQuery(predicate);
    query = querydsl.applySorting(new QSort(orders), query);
    return query.list(path);
  }
View Full Code Here

   * (non-Javadoc)
   * @see org.springframework.data.querydsl.QueryDslPredicateExecutor#findAll(com.mysema.query.types.Predicate, org.springframework.data.domain.Pageable)
   */
  public Page<T> findAll(Predicate predicate, Pageable pageable) {

    JPQLQuery countQuery = createQuery(predicate);
    JPQLQuery query = querydsl.applyPagination(pageable, createQuery(predicate));

    Long total = countQuery.count();
    List<T> content = total > pageable.getOffset() ? query.list(path) : Collections.<T> emptyList();

    return new PageImpl<T>(content, pageable, total);
  }
View Full Code Here

   * @see DATAJPA-499
   */
  @Test
  public void defaultOrderingShouldNotGenerateAnNullOrderingHint() {

    JPQLQuery result = querydsl.applySorting(new Sort(new Sort.Order("firstname")), userQuery);

    assertThat(result, is(notNullValue()));
    assertThat(result.toString(), is(not(anyOf(containsString("nulls first"), containsString("nulls last")))));
  }
View Full Code Here

  public Page<Operation> findNonCardByAccountIdAndYearMonth(Integer accountId, YearMonth yearMonth, Pageable pageable) {

    BooleanExpression predicate = operation.type.id.ne(OperationType.CARD).and(operation.account.id.eq(accountId));
    predicate = addOperationYearMonthExpression(predicate, operation, yearMonth);

    JPQLQuery countQuery = from(operation).where(predicate);
    JPQLQuery query = applyPagination(from(operation).where(predicate).orderBy(operation.date.desc()), pageable);

    return buildPage(countQuery, query, pageable);
  }
View Full Code Here

  public Page<Operation> findCardOperationsByAccountIdAndYearMonthAndStatus(Integer accountId, YearMonth yearMonth, OperationStatus status, Pageable pageable) {

    BooleanExpression predicate = operation.type.id.eq(OperationType.CARD).and(operation.account.id.eq(accountId)).and(operation.status.id.eq(status));
    predicate = addOperationYearMonthExpression(predicate, operation, yearMonth);

    JPQLQuery countQuery = from(operation).where(predicate);
    JPQLQuery query = applyPagination(from(operation).where(predicate).orderBy(operation.date.desc()), pageable);

    return buildPage(countQuery, query, pageable);
  }
View Full Code Here

  public Page<Operation> findCardOperationsByCardIdAndYearMonthAndStatus(Integer cardId, YearMonth yearMonth, OperationStatus status, Pageable pageable) {

    BooleanExpression predicate = operation.type.id.eq(OperationType.CARD).and(operation.card.id.eq(cardId)).and(operation.status.id.eq(status));
    predicate = addOperationYearMonthExpression(predicate, operation, yearMonth);

    JPQLQuery countQuery = from(operation).where(predicate);
    JPQLQuery query = applyPagination(from(operation).where(predicate).orderBy(operation.date.desc()), pageable);

    return buildPage(countQuery, query, pageable);
  }
View Full Code Here

  @Override
  public Page<Operation> findTransferByAccountId(Integer accountId, Pageable pageable) {

    BooleanExpression predicate = operation.type.id.eq(OperationType.TRANSFER).and(operation.account.id.eq(accountId));

    JPQLQuery countQuery = from(operation).where(predicate);
    JPQLQuery query = applyPagination(from(operation).where(predicate).orderBy(operation.date.desc()), pageable);

    return buildPage(countQuery, query, pageable);
  }
View Full Code Here

    @Test
    @NoBatooJPA
    public void Enum_In2() {
        QEmployee employee = QEmployee.employee;

        JPQLQuery query = query();
        query.from(employee).where(employee.lastName.eq("Smith"), employee.jobFunctions
                .contains(JobFunction.CODER));
        assertEquals(1l, query.count());
    }
View Full Code Here

TOP

Related Classes of com.mysema.query.jpa.JPQLQuery

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.