select
post0_.id as id1_3_0_,
postimages1_.id as id1_4_1_,
posttags2_.id as id1_5_2_,
tag3_.id as id1_6_3_,
couple4_.id as id1_0_4_,
post0_.created_date_time as created_2_3_0_,
post0_.updated_date_time as updated_3_3_0_,
post0_.content as content4_3_0_,
post0_.couple_id as couple_i9_3_0_,
post0_.dating_date as dating_d5_3_0_,
post0_.latitude as latitude6_3_0_,
post0_.longitude as longitud7_3_0_,
post0_.title as title8_3_0_,
postimages1_.image_url as image_ur2_4_1_,
postimages1_.post_id as post_id3_4_1_,
postimages1_.post_id as post_id3_4_0__,
postimages1_.id as id1_4_0__,
posttags2_.post_id as post_id2_5_2_,
posttags2_.tag_id as tag_id3_5_2_,
posttags2_.post_id as post_id2_5_1__,
posttags2_.id as id1_5_1__,
tag3_.color as color2_6_3_,
tag3_.couple_id as couple_i4_6_3_,
tag3_.name as name3_6_3_,
couple4_.created_date_time as created_2_0_4_,
couple4_.updated_date_time as updated_3_0_4_,
couple4_.start_date as start_da4_0_4_
from
post post0_
inner join
post_image postimages1_
on post0_.id=postimages1_.post_id
inner join
post_tag posttags2_
on post0_.id=posttags2_.post_id
inner join
tag tag3_
on posttags2_.tag_id=tag3_.id
inner join
couple couple4_
on post0_.couple_id=couple4_.id
where
post0_.id=?
태그는 중복 제거가 되지만 이미지는 제거가 안되는 모습
사실 태그는 set이라 중복제거가 가능한 것
이미지는 list라 중복이 발생하게 된다.
이미지도 Set으로 변경한다면?
중복없이 둘 다 가져온다.
하지만 이미지는 썸네일 이미지를 조회할 수 있어야 하기 때문에 순서가 중요하다.
결국
select
post0_.id as id1_3_0_,
posttags1_.id as id1_5_1_,
tag2_.id as id1_6_2_,
couple3_.id as id1_0_3_,
post0_.created_date_time as created_2_3_0_,
post0_.updated_date_time as updated_3_3_0_,
post0_.content as content4_3_0_,
post0_.couple_id as couple_i9_3_0_,
post0_.dating_date as dating_d5_3_0_,
post0_.latitude as latitude6_3_0_,
post0_.longitude as longitud7_3_0_,
post0_.title as title8_3_0_,
posttags1_.post_id as post_id2_5_1_,
posttags1_.tag_id as tag_id3_5_1_,
posttags1_.post_id as post_id2_5_0__,
posttags1_.id as id1_5_0__,
tag2_.color as color2_6_2_,
tag2_.couple_id as couple_i4_6_2_,
tag2_.name as name3_6_2_,
couple3_.created_date_time as created_2_0_3_,
couple3_.updated_date_time as updated_3_0_3_,
couple3_.start_date as start_da4_0_3_
from
post post0_
inner join
post_tag posttags1_
on post0_.id=posttags1_.post_id
inner join
tag tag2_
on posttags1_.tag_id=tag2_.id
inner join
couple couple3_
on post0_.couple_id=couple3_.id
where
post0_.id=?
select
postimages0_.post_id as post_id3_4_1_,
postimages0_.id as id1_4_1_,
postimages0_.id as id1_4_0_,
postimages0_.image_url as image_ur2_4_0_,
postimages0_.post_id as post_id3_4_0_
from
post_image postimages0_
where
postimages0_.post_id=?
List 반환이 아니라서 자동으로 중복 제거하여 반환해주는 것 같다.
List로 반환한다면?
DISTINCT 적용 시
Hibernate default_batch_fetch_size 처음엔 해당 옵션으로 해결하려 했지만 생각해보니 in절로 날리는 것이 아닌 =절로 쿼리를 수행하면 되서 필요없는 옵션이였다