Exemplo n.º 1
0
 @Override
 public Response findByReview(final Integer id) {
   final QResponse response = QResponse.response;
   JPQLQuery query = jpqlQuery();
   query.from(response).where(response.review.id.eq(id));
   return query.singleResult(response);
 }
Exemplo n.º 2
0
  @Test
  public void One_To_One() {
    QEmployee employee = QEmployee.employee;
    QUser user = QUser.user;

    JPQLQuery query = query();
    query.from(employee);
    query.innerJoin(employee.user, user);
    query.list(employee);
  }
Exemplo n.º 3
0
  @Test
  @NoBatooJPA
  public void Enum_In() {
    QEmployee employee = QEmployee.employee;

    JPQLQuery query = query();
    query
        .from(employee)
        .where(employee.lastName.eq("Smith"), employee.jobFunctions.contains(JobFunction.CODER));
    assertEquals(1l, query.count());
  }
Exemplo n.º 4
0
  @Override
  public ProductReview getById(Long id) {

    QProductReview qEntity = QProductReview.productReview;
    QProductReviewDescription qDescription = QProductReviewDescription.productReviewDescription;
    QProduct qProduct = QProduct.product;

    JPQLQuery query = new JPAQuery(getEntityManager());

    query
        .from(qEntity)
        .join(qEntity.customer)
        .fetch()
        .join(qEntity.product, qProduct)
        .fetch()
        .leftJoin(qProduct.merchantStore)
        .fetch()
        .leftJoin(qEntity.descriptions, qDescription)
        .fetch()
        .where(qEntity.id.eq(id));

    return query.uniqueResult(qEntity);
  }
Exemplo n.º 5
0
  @Override
  public List<ProductReview> getByProduct(Product product) {

    QProductReview qEntity = QProductReview.productReview;
    QProductReviewDescription qDescription = QProductReviewDescription.productReviewDescription;
    QProduct qProduct = QProduct.product;

    JPQLQuery query = new JPAQuery(getEntityManager());

    query
        .from(qEntity)
        .join(qEntity.customer)
        .fetch()
        .join(qEntity.product, qProduct)
        .fetch()
        .leftJoin(qProduct.merchantStore)
        .fetch()
        .leftJoin(qEntity.descriptions, qDescription)
        .fetch()
        .where(qProduct.id.eq(product.getId()));

    return query.list(qEntity);
  }
Exemplo n.º 6
0
  @Override
  public ProductPrice getById(Long id) {
    QProductPrice qEntity = QProductPrice.productPrice;
    QProductAvailability qAvailability = QProductAvailability.productAvailability;
    QProductPriceDescription qEntityDescription = QProductPriceDescription.productPriceDescription;
    QProduct qProduct = QProduct.product;

    JPQLQuery query = new JPAQuery(getEntityManager());

    query
        .from(qEntity)
        .innerJoin(qEntity.productAvailability, qAvailability)
        .fetch()
        .innerJoin(qAvailability.product, qProduct)
        .fetch()
        .leftJoin(qEntity.descriptions, qEntityDescription)
        .fetch()
        .innerJoin(qProduct.merchantStore)
        .fetch()
        .where(qEntity.id.eq(id));

    return query.uniqueResult(qEntity);
  }