예제 #1
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);
  }
예제 #2
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);
  }