스프링 데이터는 다음과 같은 상황에서 count 쿼리를 생략한다.
JPAQuery<Member> countQuery = queryFactory
.select(member)
.from(member)
.leftJoin(member.team, team)
.where(usernameEq(condition.getUsername()),
teamNameEq(condition.getTeamName()),
ageGoe(condition.getAgeGoe()),
ageLoe(condition.getAgeLoe()));
//return new PageImpl<>(content, pageable, total);
return PageableExecutionUtils.getPage(content, pageable, countQuery::fetchCount);
참조
https://www.inflearn.com/course/querydsl-%EC%8B%A4%EC%A0%84/dashboard