1. QueryDSL 적용 구문
@RequiredArgsConstructor
public class ReservationMonthInfoRepositoryQueryImpl implements ReservationMonthInfoRepositoryQuery{
private final JPAQueryFactory jpaQueryFactory;
@Override
public List<ReservationMonthInfoResponseDto> reservationMonthInfoByStoreId(Long storeId) {
List<ReservationMonthInfoResponseDto> result =
jpaQueryFactory.select(
Projections.bean(
ReservationMonthInfoResponseDto.class
,reservationMonthInfo.yearInfo
,reservationMonthInfo.monthInfo
))
.from(reservationMonthInfo)
.where(reservationMonthInfo.store.id.eq(storeId))
.fetch();
for(ReservationMonthInfoResponseDto rs : result){
System.out.println(rs.getYearInfo());
System.out.println(rs.getMonthInfo());
}
return result;
}
- 적용 후 PostMan Test결과

- 실제 데이터를 넣었음에도 null 값이 도출됐다.
2. 결론
- 2번의 문제였고, 해당 Dto에 set 프로퍼티 설정을 해주지 않아서, 데이터가 들어가지 않았다.
@Getter
@Setter
@NoArgsConstructor
public class ReservationMonthInfoResponseDto {
private String yearInfo;
private String monthInfo;
....}