public ReviewDTO toReviewDTO(Integer memberId, Review review) {

        List<CommentDTO> commentDTOs = review.getComments().stream()
                .map(CommentDTO::toCommentDTO)
                .toList();
        int totalComments = commentDTOs.size();

        System.out.println("//////////////////////////////////////////////////////////////////////");
        // testing
        String getClass = review.getSchedule().getClass().getName();
        System.out.println(getClass);

//        Schedule schedule = review.getSchedule();

        boolean myReviewCheck = review.getSchedule() != null &&
                review.getSchedule().getMember() != null &&
                review.getSchedule().getMember().getId() != null &&
                review.getSchedule().getMember().getId().equals(memberId);

        int size = 10; // Assuming fixed size for comment pages
        int pages = (int) Math.ceil((double) totalComments / size);

        String formattedDate =
                review.getCreateDate() != null ? review.getCreateDate().format(formatter) : null;

        boolean myEmpathy = empathyRepository.findById(new EmpathyId(review.getId(), memberId))
                .isPresent();

        String basePath = "images/";
        String filename = review.getFilename();
        String filepath;

        if ("noimg".equals(filename)) {
            // Special case for "noimg"
            filepath = ServletUriComponentsBuilder.fromCurrentContextPath()
                    .path(basePath)
                    .path("noimg.png") // or any specific path for placeholder image
                    .build()
                    .toUriString();
        } else {
            // Standard case
            filepath = ServletUriComponentsBuilder.fromCurrentContextPath()
                    .path(basePath)
                    .path(filename)
                    .build()
                    .toUriString();
        }

        Schedule schedule = review.getSchedule();
        if (schedule instanceof HibernateProxy) {
            schedule = (Schedule) ((HibernateProxy) schedule).getHibernateLazyInitializer().getImplementation();
        }

        ReviewDTOBuilder builder = ReviewDTO.builder()
                .id(review.getId())
                .scheduleId(review.getSchedule() != null ? review.getSchedule().getId() : null)
                .writer(review.getSchedule() != null && review.getSchedule().getMember() != null
                        ? review.getSchedule().getMember().getNickname() : null)
                .imgurl(filepath)
                .content(review.getContent())
                .spoiler(review.getSpoiler())
                .emotion(review.getEmotion())
                .createdate(formattedDate)
                .empathy(review.getEmphathy())
                .myempathy(myEmpathy)
                .commentpagesize(pages)
                .commentscount(totalComments)
                .myreview(myReviewCheck);

        if (schedule != null
                && schedule instanceof CustomSchedule customSchedule) {
            return builder
                    .title(customSchedule.getName() != null ? customSchedule.getName() : null)
                    .category(
                            customSchedule.getCategory() != null ? customSchedule.getCategory().toString()
                                    : null)
                    .build();
        } else if (schedule != null
                && schedule instanceof ReservationSchedule reservationSchedule) {
            return builder
                    .title(reservationSchedule.getReservationDetail().getShowSchedule().getShowDetail()
                            .getName())
                    .category(
                            reservationSchedule.getReservationDetail().getShowSchedule().getShowDetail()
                                    .getCategory().toString())
                    .build();
        }

        System.out.println("//////////////////////////////////////////////////////////////////////");
        // testing
        String getClass2 = review.getSchedule().getClass().getName();
        System.out.println(getClass2);

        return builder.build();
    }

instanceof로 계속 schedule 과 schedule 자식인 customschedule, reservationschedule 을 불렀지만 답변이 null로 나오고 위의 둘이 아닌 schedule 타입으로 나옴 ⇒ 프록시가 초기화 되지않아 생긴 현상!

Schedule schedule = review.getSchedule();
        if (schedule instanceof HibernateProxy) {
            schedule = (Schedule) ((HibernateProxy) schedule).getHibernateLazyInitializer().getImplementation();
        }

이 문장을 추가하여 프록시를 초기화하고 schedule을 넣어주면 초기화 되어 나온다!

⇒ 프록시는 뭐고 불러서 쓰는데 초기화는 왜…?