Jpa/querydsl
jpa querydsl group by 예제 설명
무대포 개발자
2020. 11. 28. 11:00
728x90
반응형
jpa querydsl group by 예제 설명
@RequiredArgsConstructor
public class XXXImpl implments xxxCustom {
private final JPAQueryFactory queryFactory;
public List<TestIO> xxxFunction(String startDate, String endDate) {
QTest qTest = QTest.qTest;
return queryFactory.from(qTest)
.groupBy(qTest.x1, qTest.x2)
.select(
Projections.bean(
TestIO.class
,qTest.x1
,qTest.x2
,qTest.num.sum().as("numSum")
)
.where(qTest.testDate.between(startDate, endDate))
.fetch();
}
}