💣 문제

호텔 API호출

image.png

결과값 20개

image.png

20개의 PhotoEntity 조회 쿼리가 나감

Hibernate: 
    select
        distinct he1_0.hotel_id,
        he1_0.address,
        he1_0.description,
        he1_0.latitude,
        he1_0.longitude,
        he1_0.name,
        he1_0.provider_id,
        he1_0.rating,
        he1_0.review_count,
        he1_0.star_level 
    from
        hotel_entity he1_0 
    join
        room_entity re1_0 
            on re1_0.hotel_id=he1_0.hotel_id 
    left join
        reservation_entity re2_0 
            on re2_0.hotel_id=he1_0.hotel_id 
    left join
        reserved_room_entity rre1_0 
            on rre1_0.reservation_id=re2_0.reservation_id 
    where
        he1_0.latitude between ? and ? 
        and he1_0.longitude between ? and ? 
        and re1_0.total_quantity>(
            select
                coalesce(sum(rre2_0.quantity), ?) 
            from
                reserved_room_entity rre2_0 
            join
                reservation_entity r2_0 
                    on r2_0.reservation_id=rre2_0.reservation_id 
            where
                rre2_0.room_id=re1_0.room_id 
                and r2_0.check_in_date<? 
                and r2_0.check_out_date>?
        ) 
        and (
            st_distance_sphere(point(he1_0.longitude, he1_0.latitude), point(?, ?))/?
        )<=? 
    order by
        (st_distance_sphere(point(he1_0.longitude, he1_0.latitude), point(?, ?))/?) 
    limit
        ?, ?
Hibernate: 
    select
        count(distinct he1_0.hotel_id) 
    from
        hotel_entity he1_0 
    join
        room_entity re1_0 
            on re1_0.hotel_id=he1_0.hotel_id 
    left join
        reservation_entity re2_0 
            on re2_0.hotel_id=he1_0.hotel_id 
    left join
        reserved_room_entity rre1_0 
            on rre1_0.reservation_id=re2_0.reservation_id 
    where
        he1_0.latitude between ? and ? 
        and he1_0.longitude between ? and ? 
        and re1_0.total_quantity>(
            select
                coalesce(sum(rre2_0.quantity), ?) 
            from
                reserved_room_entity rre2_0 
            join
                reservation_entity r2_0 
                    on r2_0.reservation_id=rre2_0.reservation_id 
            where
                rre2_0.room_id=re1_0.room_id 
                and r2_0.check_in_date<? 
                and r2_0.check_out_date>?
        ) 
        and (
            st_distance_sphere(point(he1_0.longitude, he1_0.latitude), point(?, ?))/?
        )<=?
Hibernate: 
    **select  
        p1_0.hotel_id,**
        p1_0.photo_id,
        p1_0.created_at,
        p1_0.display_type,
        p1_0.room_id,
        p1_0.stored_file_name,
        p1_0.upload_file_name 
    from
        photo_entity p1_0 
    where
        p1_0.hotel_id=?
Hibernate: 
    **select
        p1_0.hotel_id,**
        p1_0.photo_id,
        p1_0.created_at,
        p1_0.display_type,
        p1_0.room_id,
        p1_0.stored_file_name,
        p1_0.upload_file_name 
    from
        photo_entity p1_0 
    where
        p1_0.hotel_id=?
Hibernate: 
    **select
        p1_0.hotel_id,**
        p1_0.photo_id,
        p1_0.created_at,
        p1_0.display_type,
        p1_0.room_id,
        p1_0.stored_file_name,
        p1_0.upload_file_name 
    from
        photo_entity p1_0 
    where
        p1_0.hotel_id=?
Hibernate: 
    **select
        p1_0.hotel_id,
        p1_0.photo_id,**
        p1_0.created_at,
        p1_0.display_type,
        p1_0.room_id,
        p1_0.stored_file_name,
        p1_0.upload_file_name 
    **from
        photo_entity p1_0** 
    where
        p1_0.hotel_id=?
Hibernate: 
    **select
        p1_0.hotel_id,**
        p1_0.photo_id,
        p1_0.created_at,
        p1_0.display_type,
        p1_0.room_id,
        p1_0.stored_file_name,
        p1_0.upload_file_name 
    from
        photo_entity p1_0 
    where
        p1_0.hotel_id=?
Hibernate: 
    **select
        p1_0.hotel_id,**
        p1_0.photo_id,
        p1_0.created_at,
        p1_0.display_type,
        p1_0.room_id,
        p1_0.stored_file_name,
        p1_0.upload_file_name 
    from
        photo_entity p1_0 
    where
        p1_0.hotel_id=?
Hibernate: 
    **select
        p1_0.hotel_id,**
        p1_0.photo_id,
        p1_0.created_at,
        p1_0.display_type,
        p1_0.room_id,
        p1_0.stored_file_name,
        p1_0.upload_file_name 
    from
        photo_entity p1_0 
    where
        p1_0.hotel_id=?
Hibernate: 
    **select
        p1_0.hotel_id,**
        p1_0.photo_id,
        p1_0.created_at,
        p1_0.display_type,
        p1_0.room_id,
        p1_0.stored_file_name,
        p1_0.upload_file_name 
    from
        photo_entity p1_0 
    where
        p1_0.hotel_id=?
Hibernate: 
    **select
        p1_0.hotel_id,  // 10개**
        p1_0.photo_id,
        p1_0.created_at,
        p1_0.display_type,
        p1_0.room_id,
        p1_0.stored_file_name,
        p1_0.upload_file_name 
    from
        photo_entity p1_0 
    where
        p1_0.hotel_id=?
Hibernate: 
    **select
        p1_0.hotel_id,**
        p1_0.photo_id,
        p1_0.created_at,
        p1_0.display_type,
        p1_0.room_id,
        p1_0.stored_file_name,
        p1_0.upload_file_name 
    from
        photo_entity p1_0 
    where
        p1_0.hotel_id=?
Hibernate: 
    **select
        p1_0.hotel_id,**
        p1_0.photo_id,
        p1_0.created_at,
        p1_0.display_type,
        p1_0.room_id,
        p1_0.stored_file_name,
        p1_0.upload_file_name 
    from
        photo_entity p1_0 
    where
        p1_0.hotel_id=?
Hibernate: 
    **select
        p1_0.hotel_id,**
        p1_0.photo_id,
        p1_0.created_at,
        p1_0.display_type,
        p1_0.room_id,
        p1_0.stored_file_name,
        p1_0.upload_file_name 
    from
        photo_entity p1_0 
    where
        p1_0.hotel_id=?
Hibernate: 
    **select
        p1_0.hotel_id,**
        p1_0.photo_id,
        p1_0.created_at,
        p1_0.display_type,
        p1_0.room_id,
        p1_0.stored_file_name,
        p1_0.upload_file_name 
    from
        photo_entity p1_0 
    where
        p1_0.hotel_id=?
Hibernate: 
    s**elect
        p1_0.hotel_id,**
        p1_0.photo_id,
        p1_0.created_at,
        p1_0.display_type,
        p1_0.room_id,
        p1_0.stored_file_name,
        p1_0.upload_file_name 
    from
        photo_entity p1_0 
    where
        p1_0.hotel_id=?
Hibernate: 
    **select**
        p1_0.hotel_id,
        **p1_0.photo_id,**
        p1_0.created_at,
        p1_0.display_type,
        p1_0.room_id,
        p1_0.stored_file_name,
        p1_0.upload_file_name 
    from
        photo_entity p1_0 
    where
        p1_0.hotel_id=?
Hibernate: 
    **select
        p1_0.hotel_id,
        p1_0.photo_id,**
        p1_0.created_at,
        p1_0.display_type,
        p1_0.room_id,
        p1_0.stored_file_name,
        p1_0.upload_file_name 
    from
        photo_entity p1_0 
    where
        p1_0.hotel_id=?
Hibernate: 
    s**elect
        p1_0.hotel_id,**
        **p1_0.photo_id,**
        p1_0.created_at,
        p1_0.display_type,
        p1_0.room_id,
        p1_0.stored_file_name,
        p1_0.upload_file_name 
    from
        photo_entity p1_0 
    where
        p1_0.hotel_id=?
Hibernate: 
    se**lect
        p1_0.hotel_id,
        p1_0.photo_id,**
        p1_0.created_at,
        p1_0.display_type,
        p1_0.room_id,
        p1_0.stored_file_name,
        p1_0.upload_file_name 
    from
        photo_entity p1_0 
    where
        p1_0.hotel_id=?
Hibernate: 
    **select
        p1_0.hotel_id,**
        **p1_0.photo_id,**
        p1_0.created_at,
        p1_0.display_type,
        p1_0.room_id,
        p1_0.stored_file_name,
        p1_0.upload_file_name 
    from
        photo_entity p1_0 
    where
        p1_0.hotel_id=?
Hibernate: 
    **select
        p1_0.hotel_id,**
        **p1_0.photo_id,**
        p1_0.created_at,
        p1_0.display_type,
        p1_0.room_id,
        p1_0.stored_file_name,
        p1_0.upload_file_name 
    from
        photo_entity p1_0 
    where
        p1_0.hotel_id=?

🍧 문제 지점

Repository 레이어의 searchNearbyHotels()은 근방 available한 방이 있는 호텔을 찾음

그리고 HotelSearchService에서 결과값은 HotelListResponse (DTO)로 변환함

image.png

HotelListResponse

public record GetHotelListResponse(
        Integer hotelId,
        String name,
        String address,
        Integer starLevel,
        Double rating,
        Integer reviewCount,
        String mainImageUrl
) {}