jpa querydsl連表一対多クエリー

543 ワード

Map sm = jpaQuery.from(qOrder)
        .leftJoin(qProduct)
        .on(qOrder.productId.eq(qProduct.id))
        .select(Projections.bean(OrderViewModel.class,
                  qOrder.code1
                ))
        .transform(GroupBy.groupBy(qOrder.code1).as(Projections.bean(OrderViewModel.class,
                qOrder.code1,
                GroupBy.list(Projections.bean(ProductViewModel.class,
                        qProduct.name
                )).as("productViewModels")
        )));