1. 서론
연관관계 테이블이 늘어나면서
캐릭터 데이터를 호출할 때 SQL문이 여러번 실행된다.
1 - 1. 기존코드
@Query(value = "SELECT c FROM Character c WHERE c.member = :member AND c.serverName = :serverName")
List<Character> findCharacterListServerName(@Param("member") Member member, @Param("serverName") String serverName);
JPA로 Member Entity를 불러와서 Controller에서 DTO로 변경할 때
필요한 데이터들을 LAZY 형식으로 불러온다.
1 - 2. 기존코드 결과
2023-11-24 17:32:29.777 DEBUG 39633 --- [nio-8080-exec-6] org.hibernate.SQL :
select
member0_.member_id as member_i1_10_,
member0_.created_date as created_2_10_,
member0_.last_modified_date as last_mod3_10_,
member0_.access_key as access_k4_10_,
member0_.api_key as api_key5_10_,
member0_.auth_provider as auth_pro6_10_,
member0_.password as password7_10_,
member0_.role as role8_10_,
member0_.username as username9_10_
from
member member0_
where
member0_.username=?
2023-11-24 17:32:29.783 DEBUG 39633 --- [nio-8080-exec-6] org.hibernate.SQL :
select
characters0_.member_id as member_38_0_0_,
characters0_.characters_id as characte1_0_0_,
characters0_.characters_id as characte1_0_1_,
characters0_.created_date as created_2_0_1_,
characters0_.last_modified_date as last_mod3_0_1_,
characters0_.challenge_abyss as challeng4_0_1_,
characters0_.challenge_guardian as challeng5_0_1_,
characters0_.character_class_name as characte6_0_1_,
characters0_.character_image as characte7_0_1_,
characters0_.character_level as characte8_0_1_,
characters0_.character_name as characte9_0_1_,
characters0_.chaos_id as chaos_i36_0_1_,
characters0_.chaos_check as chaos_c10_0_1_,
characters0_.chaos_gauge as chaos_g11_0_1_,
characters0_.chaos_gold as chaos_g12_0_1_,
characters0_.chaos_name as chaos_n13_0_1_,
characters0_.epona_check as epona_c14_0_1_,
characters0_.epona_check2 as epona_c15_0_1_,
characters0_.epona_gauge as epona_g16_0_1_,
characters0_.guardian_id as guardia37_0_1_,
characters0_.guardian_check as guardia17_0_1_,
characters0_.guardian_gauge as guardia18_0_1_,
characters0_.guardian_gold as guardia19_0_1_,
characters0_.guardian_name as guardia20_0_1_,
characters0_.gold_character as gold_ch21_0_1_,
characters0_.item_level as item_le22_0_1_,
characters0_.member_id as member_38_0_1_,
characters0_.server_name as server_23_0_1_,
characters0_.show_chaos as show_ch24_0_1_,
characters0_.show_character as show_ch25_0_1_,
characters0_.show_cube_ticket as show_cu26_0_1_,
characters0_.show_epona as show_ep27_0_1_,
characters0_.show_guardian as show_gu28_0_1_,
characters0_.show_silmael_change as show_si29_0_1_,
characters0_.show_week_epona as show_we30_0_1_,
characters0_.show_week_todo as show_we31_0_1_,
characters0_.sort_number as sort_nu32_0_1_,
characters0_.cube_ticket as cube_ti33_0_1_,
characters0_.silmael_change as silmael34_0_1_,
characters0_.week_epona as week_ep35_0_1_,
daycontent1_.content_id as content_2_4_2_,
daycontent1_.category as category3_4_2_,
daycontent1_.level as level4_4_2_,
daycontent1_.name as name5_4_2_,
daycontent1_.destruction_stone as destruc13_4_2_,
daycontent1_.guardian_stone as guardia14_4_2_,
daycontent1_.honor_shard as honor_s15_4_2_,
daycontent1_.jewelry as jewelry7_4_2_,
daycontent1_.leap_stone as leap_sto8_4_2_,
daycontent1_.shilling as shilling9_4_2_,
daycontent2_.content_id as content_2_4_3_,
daycontent2_.category as category3_4_3_,
daycontent2_.level as level4_4_3_,
daycontent2_.name as name5_4_3_,
daycontent2_.destruction_stone as destruc13_4_3_,
daycontent2_.guardian_stone as guardia14_4_3_,
daycontent2_.honor_shard as honor_s15_4_3_,
daycontent2_.jewelry as jewelry7_4_3_,
daycontent2_.leap_stone as leap_sto8_4_3_,
daycontent2_.shilling as shilling9_4_3_
from
characters characters0_
left outer join
content daycontent1_
on characters0_.chaos_id=daycontent1_.content_id
left outer join
content daycontent2_
on characters0_.guardian_id=daycontent2_.content_id
where
characters0_.member_id=?
2023-11-24 17:32:29.804 DEBUG 39633 --- [nio-8080-exec-6] org.hibernate.SQL :
select
character0_.characters_id as characte1_0_,
character0_.created_date as created_2_0_,
character0_.last_modified_date as last_mod3_0_,
character0_.challenge_abyss as challeng4_0_,
character0_.challenge_guardian as challeng5_0_,
character0_.character_class_name as characte6_0_,
character0_.character_image as characte7_0_,
character0_.character_level as characte8_0_,
character0_.character_name as characte9_0_,
character0_.chaos_id as chaos_i36_0_,
character0_.chaos_check as chaos_c10_0_,
character0_.chaos_gauge as chaos_g11_0_,
character0_.chaos_gold as chaos_g12_0_,
character0_.chaos_name as chaos_n13_0_,
character0_.epona_check as epona_c14_0_,
character0_.epona_check2 as epona_c15_0_,
character0_.epona_gauge as epona_g16_0_,
character0_.guardian_id as guardia37_0_,
character0_.guardian_check as guardia17_0_,
character0_.guardian_gauge as guardia18_0_,
character0_.guardian_gold as guardia19_0_,
character0_.guardian_name as guardia20_0_,
character0_.gold_character as gold_ch21_0_,
character0_.item_level as item_le22_0_,
character0_.member_id as member_38_0_,
character0_.server_name as server_23_0_,
character0_.show_chaos as show_ch24_0_,
character0_.show_character as show_ch25_0_,
character0_.show_cube_ticket as show_cu26_0_,
character0_.show_epona as show_ep27_0_,
character0_.show_guardian as show_gu28_0_,
character0_.show_silmael_change as show_si29_0_,
character0_.show_week_epona as show_we30_0_,
character0_.show_week_todo as show_we31_0_,
character0_.sort_number as sort_nu32_0_,
character0_.cube_ticket as cube_ti33_0_,
character0_.silmael_change as silmael34_0_,
character0_.week_epona as week_ep35_0_
from
characters character0_
where
character0_.member_id=?
and character0_.server_name=?
2023-11-24 17:32:29.807 DEBUG 39633 --- [nio-8080-exec-6] org.hibernate.SQL :
select
todov2list0_.character_id as characte8_15_0_,
todov2list0_.todo_id as todo_id1_15_0_,
todov2list0_.todo_id as todo_id1_15_1_,
todov2list0_.created_date as created_2_15_1_,
todov2list0_.last_modified_date as last_mod3_15_1_,
todov2list0_.character_id as characte8_15_1_,
todov2list0_.cool_time as cool_tim4_15_1_,
todov2list0_.gold as gold5_15_1_,
todov2list0_.is_checked as is_check6_15_1_,
todov2list0_.message as message7_15_1_,
todov2list0_.content_id as content_9_15_1_
from
todov2 todov2list0_
where
todov2list0_.character_id=?
2023-11-24 17:32:29.809 DEBUG 39633 --- [nio-8080-exec-6] org.hibernate.SQL :
select
weekconten0_.content_id as content_2_4_0_,
weekconten0_.category as category3_4_0_,
weekconten0_.level as level4_4_0_,
weekconten0_.name as name5_4_0_,
weekconten0_.cool_time as cool_ti16_4_0_,
weekconten0_.destruction_stone as destruc13_4_0_,
weekconten0_.gate as gate17_4_0_,
weekconten0_.gold as gold18_4_0_,
weekconten0_.guardian_stone as guardia14_4_0_,
weekconten0_.honor_shard as honor_s15_4_0_,
weekconten0_.leap_stone as leap_sto8_4_0_,
weekconten0_.week_category as week_ca19_4_0_,
weekconten0_.week_content_category as week_co20_4_0_
from
content weekconten0_
where
weekconten0_.content_id=?
and weekconten0_.dtype='WeekContent'
2023-11-24 17:32:29.811 DEBUG 39633 --- [nio-8080-exec-6] org.hibernate.SQL :
select
weekconten0_.content_id as content_2_4_0_,
weekconten0_.category as category3_4_0_,
weekconten0_.level as level4_4_0_,
weekconten0_.name as name5_4_0_,
weekconten0_.cool_time as cool_ti16_4_0_,
weekconten0_.destruction_stone as destruc13_4_0_,
weekconten0_.gate as gate17_4_0_,
weekconten0_.gold as gold18_4_0_,
weekconten0_.guardian_stone as guardia14_4_0_,
weekconten0_.honor_shard as honor_s15_4_0_,
weekconten0_.leap_stone as leap_sto8_4_0_,
weekconten0_.week_category as week_ca19_4_0_,
weekconten0_.week_content_category as week_co20_4_0_
from
content weekconten0_
where
weekconten0_.content_id=?
and weekconten0_.dtype='WeekContent'
2023-11-24 17:32:29.812 DEBUG 39633 --- [nio-8080-exec-6] org.hibernate.SQL :
select
weekconten0_.content_id as content_2_4_0_,
weekconten0_.category as category3_4_0_,
weekconten0_.level as level4_4_0_,
weekconten0_.name as name5_4_0_,
weekconten0_.cool_time as cool_ti16_4_0_,
weekconten0_.destruction_stone as destruc13_4_0_,
weekconten0_.gate as gate17_4_0_,
weekconten0_.gold as gold18_4_0_,
weekconten0_.guardian_stone as guardia14_4_0_,
weekconten0_.honor_shard as honor_s15_4_0_,
weekconten0_.leap_stone as leap_sto8_4_0_,
weekconten0_.week_category as week_ca19_4_0_,
weekconten0_.week_content_category as week_co20_4_0_
from
content weekconten0_
where
weekconten0_.content_id=?
and weekconten0_.dtype='WeekContent'
2023-11-24 17:32:29.812 DEBUG 39633 --- [nio-8080-exec-6] org.hibernate.SQL :
select
weekconten0_.content_id as content_2_4_0_,
weekconten0_.category as category3_4_0_,
weekconten0_.level as level4_4_0_,
weekconten0_.name as name5_4_0_,
weekconten0_.cool_time as cool_ti16_4_0_,
weekconten0_.destruction_stone as destruc13_4_0_,
weekconten0_.gate as gate17_4_0_,
weekconten0_.gold as gold18_4_0_,
weekconten0_.guardian_stone as guardia14_4_0_,
weekconten0_.honor_shard as honor_s15_4_0_,
weekconten0_.leap_stone as leap_sto8_4_0_,
weekconten0_.week_category as week_ca19_4_0_,
weekconten0_.week_content_category as week_co20_4_0_
from
content weekconten0_
where
weekconten0_.content_id=?
and weekconten0_.dtype='WeekContent'
2023-11-24 17:32:29.813 DEBUG 39633 --- [nio-8080-exec-6] org.hibernate.SQL :
select
weekconten0_.content_id as content_2_4_0_,
weekconten0_.category as category3_4_0_,
weekconten0_.level as level4_4_0_,
weekconten0_.name as name5_4_0_,
weekconten0_.cool_time as cool_ti16_4_0_,
weekconten0_.destruction_stone as destruc13_4_0_,
weekconten0_.gate as gate17_4_0_,
weekconten0_.gold as gold18_4_0_,
weekconten0_.guardian_stone as guardia14_4_0_,
weekconten0_.honor_shard as honor_s15_4_0_,
weekconten0_.leap_stone as leap_sto8_4_0_,
weekconten0_.week_category as week_ca19_4_0_,
weekconten0_.week_content_category as week_co20_4_0_
from
content weekconten0_
where
weekconten0_.content_id=?
and weekconten0_.dtype='WeekContent'
2023-11-24 17:32:29.814 DEBUG 39633 --- [nio-8080-exec-6] org.hibernate.SQL :
select
weekconten0_.content_id as content_2_4_0_,
weekconten0_.category as category3_4_0_,
weekconten0_.level as level4_4_0_,
weekconten0_.name as name5_4_0_,
weekconten0_.cool_time as cool_ti16_4_0_,
weekconten0_.destruction_stone as destruc13_4_0_,
weekconten0_.gate as gate17_4_0_,
weekconten0_.gold as gold18_4_0_,
weekconten0_.guardian_stone as guardia14_4_0_,
weekconten0_.honor_shard as honor_s15_4_0_,
weekconten0_.leap_stone as leap_sto8_4_0_,
weekconten0_.week_category as week_ca19_4_0_,
weekconten0_.week_content_category as week_co20_4_0_
from
content weekconten0_
where
weekconten0_.content_id=?
and weekconten0_.dtype='WeekContent'
2023-11-24 17:32:29.814 DEBUG 39633 --- [nio-8080-exec-6] org.hibernate.SQL :
select
weekconten0_.content_id as content_2_4_0_,
weekconten0_.category as category3_4_0_,
weekconten0_.level as level4_4_0_,
weekconten0_.name as name5_4_0_,
weekconten0_.cool_time as cool_ti16_4_0_,
weekconten0_.destruction_stone as destruc13_4_0_,
weekconten0_.gate as gate17_4_0_,
weekconten0_.gold as gold18_4_0_,
weekconten0_.guardian_stone as guardia14_4_0_,
weekconten0_.honor_shard as honor_s15_4_0_,
weekconten0_.leap_stone as leap_sto8_4_0_,
weekconten0_.week_category as week_ca19_4_0_,
weekconten0_.week_content_category as week_co20_4_0_
from
content weekconten0_
where
weekconten0_.content_id=?
and weekconten0_.dtype='WeekContent'
2023-11-24 17:32:29.815 DEBUG 39633 --- [nio-8080-exec-6] org.hibernate.SQL :
select
weekconten0_.content_id as content_2_4_0_,
weekconten0_.category as category3_4_0_,
weekconten0_.level as level4_4_0_,
weekconten0_.name as name5_4_0_,
weekconten0_.cool_time as cool_ti16_4_0_,
weekconten0_.destruction_stone as destruc13_4_0_,
weekconten0_.gate as gate17_4_0_,
weekconten0_.gold as gold18_4_0_,
weekconten0_.guardian_stone as guardia14_4_0_,
weekconten0_.honor_shard as honor_s15_4_0_,
weekconten0_.leap_stone as leap_sto8_4_0_,
weekconten0_.week_category as week_ca19_4_0_,
weekconten0_.week_content_category as week_co20_4_0_
from
content weekconten0_
where
weekconten0_.content_id=?
and weekconten0_.dtype='WeekContent'
2023-11-24 17:32:29.816 DEBUG 39633 --- [nio-8080-exec-6] org.hibernate.SQL :
select
weekconten0_.content_id as content_2_4_0_,
weekconten0_.category as category3_4_0_,
weekconten0_.level as level4_4_0_,
weekconten0_.name as name5_4_0_,
weekconten0_.cool_time as cool_ti16_4_0_,
weekconten0_.destruction_stone as destruc13_4_0_,
weekconten0_.gate as gate17_4_0_,
weekconten0_.gold as gold18_4_0_,
weekconten0_.guardian_stone as guardia14_4_0_,
weekconten0_.honor_shard as honor_s15_4_0_,
weekconten0_.leap_stone as leap_sto8_4_0_,
weekconten0_.week_category as week_ca19_4_0_,
weekconten0_.week_content_category as week_co20_4_0_
from
content weekconten0_
where
weekconten0_.content_id=?
and weekconten0_.dtype='WeekContent'
2023-11-24 17:32:29.817 DEBUG 39633 --- [nio-8080-exec-6] org.hibernate.SQL :
select
weekconten0_.content_id as content_2_4_0_,
weekconten0_.category as category3_4_0_,
weekconten0_.level as level4_4_0_,
weekconten0_.name as name5_4_0_,
weekconten0_.cool_time as cool_ti16_4_0_,
weekconten0_.destruction_stone as destruc13_4_0_,
weekconten0_.gate as gate17_4_0_,
weekconten0_.gold as gold18_4_0_,
weekconten0_.guardian_stone as guardia14_4_0_,
weekconten0_.honor_shard as honor_s15_4_0_,
weekconten0_.leap_stone as leap_sto8_4_0_,
weekconten0_.week_category as week_ca19_4_0_,
weekconten0_.week_content_category as week_co20_4_0_
from
content weekconten0_
where
weekconten0_.content_id=?
and weekconten0_.dtype='WeekContent'
2023-11-24 17:32:29.818 DEBUG 39633 --- [nio-8080-exec-6] org.hibernate.SQL :
select
todov2list0_.character_id as characte8_15_0_,
todov2list0_.todo_id as todo_id1_15_0_,
todov2list0_.todo_id as todo_id1_15_1_,
todov2list0_.created_date as created_2_15_1_,
todov2list0_.last_modified_date as last_mod3_15_1_,
todov2list0_.character_id as characte8_15_1_,
todov2list0_.cool_time as cool_tim4_15_1_,
todov2list0_.gold as gold5_15_1_,
todov2list0_.is_checked as is_check6_15_1_,
todov2list0_.message as message7_15_1_,
todov2list0_.content_id as content_9_15_1_
from
todov2 todov2list0_
where
todov2list0_.character_id=?
2023-11-24 17:32:29.819 DEBUG 39633 --- [nio-8080-exec-6] org.hibernate.SQL :
select
todov2list0_.character_id as characte8_15_0_,
todov2list0_.todo_id as todo_id1_15_0_,
todov2list0_.todo_id as todo_id1_15_1_,
todov2list0_.created_date as created_2_15_1_,
todov2list0_.last_modified_date as last_mod3_15_1_,
todov2list0_.character_id as characte8_15_1_,
todov2list0_.cool_time as cool_tim4_15_1_,
todov2list0_.gold as gold5_15_1_,
todov2list0_.is_checked as is_check6_15_1_,
todov2list0_.message as message7_15_1_,
todov2list0_.content_id as content_9_15_1_
from
todov2 todov2list0_
where
todov2list0_.character_id=?
2023-11-24 17:32:29.820 DEBUG 39633 --- [nio-8080-exec-6] org.hibernate.SQL :
select
weekconten0_.content_id as content_2_4_0_,
weekconten0_.category as category3_4_0_,
weekconten0_.level as level4_4_0_,
weekconten0_.name as name5_4_0_,
weekconten0_.cool_time as cool_ti16_4_0_,
weekconten0_.destruction_stone as destruc13_4_0_,
weekconten0_.gate as gate17_4_0_,
weekconten0_.gold as gold18_4_0_,
weekconten0_.guardian_stone as guardia14_4_0_,
weekconten0_.honor_shard as honor_s15_4_0_,
weekconten0_.leap_stone as leap_sto8_4_0_,
weekconten0_.week_category as week_ca19_4_0_,
weekconten0_.week_content_category as week_co20_4_0_
from
content weekconten0_
where
weekconten0_.content_id=?
and weekconten0_.dtype='WeekContent'
2023-11-24 17:32:29.821 DEBUG 39633 --- [nio-8080-exec-6] org.hibernate.SQL :
select
weekconten0_.content_id as content_2_4_0_,
weekconten0_.category as category3_4_0_,
weekconten0_.level as level4_4_0_,
weekconten0_.name as name5_4_0_,
weekconten0_.cool_time as cool_ti16_4_0_,
weekconten0_.destruction_stone as destruc13_4_0_,
weekconten0_.gate as gate17_4_0_,
weekconten0_.gold as gold18_4_0_,
weekconten0_.guardian_stone as guardia14_4_0_,
weekconten0_.honor_shard as honor_s15_4_0_,
weekconten0_.leap_stone as leap_sto8_4_0_,
weekconten0_.week_category as week_ca19_4_0_,
weekconten0_.week_content_category as week_co20_4_0_
from
content weekconten0_
where
weekconten0_.content_id=?
and weekconten0_.dtype='WeekContent'
2023-11-24 17:32:29.822 DEBUG 39633 --- [nio-8080-exec-6] org.hibernate.SQL :
select
weekconten0_.content_id as content_2_4_0_,
weekconten0_.category as category3_4_0_,
weekconten0_.level as level4_4_0_,
weekconten0_.name as name5_4_0_,
weekconten0_.cool_time as cool_ti16_4_0_,
weekconten0_.destruction_stone as destruc13_4_0_,
weekconten0_.gate as gate17_4_0_,
weekconten0_.gold as gold18_4_0_,
weekconten0_.guardian_stone as guardia14_4_0_,
weekconten0_.honor_shard as honor_s15_4_0_,
weekconten0_.leap_stone as leap_sto8_4_0_,
weekconten0_.week_category as week_ca19_4_0_,
weekconten0_.week_content_category as week_co20_4_0_
from
content weekconten0_
where
weekconten0_.content_id=?
and weekconten0_.dtype='WeekContent'
2023-11-24 17:32:29.823 DEBUG 39633 --- [nio-8080-exec-6] org.hibernate.SQL :
select
todov2list0_.character_id as characte8_15_0_,
todov2list0_.todo_id as todo_id1_15_0_,
todov2list0_.todo_id as todo_id1_15_1_,
todov2list0_.created_date as created_2_15_1_,
todov2list0_.last_modified_date as last_mod3_15_1_,
todov2list0_.character_id as characte8_15_1_,
todov2list0_.cool_time as cool_tim4_15_1_,
todov2list0_.gold as gold5_15_1_,
todov2list0_.is_checked as is_check6_15_1_,
todov2list0_.message as message7_15_1_,
todov2list0_.content_id as content_9_15_1_
from
todov2 todov2list0_
where
todov2list0_.character_id=?
2023-11-24 17:32:29.824 DEBUG 39633 --- [nio-8080-exec-6] org.hibernate.SQL :
select
todov2list0_.character_id as characte8_15_0_,
todov2list0_.todo_id as todo_id1_15_0_,
todov2list0_.todo_id as todo_id1_15_1_,
todov2list0_.created_date as created_2_15_1_,
todov2list0_.last_modified_date as last_mod3_15_1_,
todov2list0_.character_id as characte8_15_1_,
todov2list0_.cool_time as cool_tim4_15_1_,
todov2list0_.gold as gold5_15_1_,
todov2list0_.is_checked as is_check6_15_1_,
todov2list0_.message as message7_15_1_,
todov2list0_.content_id as content_9_15_1_
from
todov2 todov2list0_
where
todov2list0_.character_id=?
2023-11-24 17:32:29.825 DEBUG 39633 --- [nio-8080-exec-6] org.hibernate.SQL :
select
weekconten0_.content_id as content_2_4_0_,
weekconten0_.category as category3_4_0_,
weekconten0_.level as level4_4_0_,
weekconten0_.name as name5_4_0_,
weekconten0_.cool_time as cool_ti16_4_0_,
weekconten0_.destruction_stone as destruc13_4_0_,
weekconten0_.gate as gate17_4_0_,
weekconten0_.gold as gold18_4_0_,
weekconten0_.guardian_stone as guardia14_4_0_,
weekconten0_.honor_shard as honor_s15_4_0_,
weekconten0_.leap_stone as leap_sto8_4_0_,
weekconten0_.week_category as week_ca19_4_0_,
weekconten0_.week_content_category as week_co20_4_0_
from
content weekconten0_
where
weekconten0_.content_id=?
and weekconten0_.dtype='WeekContent'
2023-11-24 17:32:29.826 DEBUG 39633 --- [nio-8080-exec-6] org.hibernate.SQL :
select
weekconten0_.content_id as content_2_4_0_,
weekconten0_.category as category3_4_0_,
weekconten0_.level as level4_4_0_,
weekconten0_.name as name5_4_0_,
weekconten0_.cool_time as cool_ti16_4_0_,
weekconten0_.destruction_stone as destruc13_4_0_,
weekconten0_.gate as gate17_4_0_,
weekconten0_.gold as gold18_4_0_,
weekconten0_.guardian_stone as guardia14_4_0_,
weekconten0_.honor_shard as honor_s15_4_0_,
weekconten0_.leap_stone as leap_sto8_4_0_,
weekconten0_.week_category as week_ca19_4_0_,
weekconten0_.week_content_category as week_co20_4_0_
from
content weekconten0_
where
weekconten0_.content_id=?
and weekconten0_.dtype='WeekContent'
2023-11-24 17:32:29.827 DEBUG 39633 --- [nio-8080-exec-6] org.hibernate.SQL :
select
weekconten0_.content_id as content_2_4_0_,
weekconten0_.category as category3_4_0_,
weekconten0_.level as level4_4_0_,
weekconten0_.name as name5_4_0_,
weekconten0_.cool_time as cool_ti16_4_0_,
weekconten0_.destruction_stone as destruc13_4_0_,
weekconten0_.gate as gate17_4_0_,
weekconten0_.gold as gold18_4_0_,
weekconten0_.guardian_stone as guardia14_4_0_,
weekconten0_.honor_shard as honor_s15_4_0_,
weekconten0_.leap_stone as leap_sto8_4_0_,
weekconten0_.week_category as week_ca19_4_0_,
weekconten0_.week_content_category as week_co20_4_0_
from
content weekconten0_
where
weekconten0_.content_id=?
and weekconten0_.dtype='WeekContent'
2023-11-24 17:32:29.828 DEBUG 39633 --- [nio-8080-exec-6] org.hibernate.SQL :
select
weekconten0_.content_id as content_2_4_0_,
weekconten0_.category as category3_4_0_,
weekconten0_.level as level4_4_0_,
weekconten0_.name as name5_4_0_,
weekconten0_.cool_time as cool_ti16_4_0_,
weekconten0_.destruction_stone as destruc13_4_0_,
weekconten0_.gate as gate17_4_0_,
weekconten0_.gold as gold18_4_0_,
weekconten0_.guardian_stone as guardia14_4_0_,
weekconten0_.honor_shard as honor_s15_4_0_,
weekconten0_.leap_stone as leap_sto8_4_0_,
weekconten0_.week_category as week_ca19_4_0_,
weekconten0_.week_content_category as week_co20_4_0_
from
content weekconten0_
where
weekconten0_.content_id=?
and weekconten0_.dtype='WeekContent'
2023-11-24 17:32:29.829 DEBUG 39633 --- [nio-8080-exec-6] org.hibernate.SQL :
select
todov2list0_.character_id as characte8_15_0_,
todov2list0_.todo_id as todo_id1_15_0_,
todov2list0_.todo_id as todo_id1_15_1_,
todov2list0_.created_date as created_2_15_1_,
todov2list0_.last_modified_date as last_mod3_15_1_,
todov2list0_.character_id as characte8_15_1_,
todov2list0_.cool_time as cool_tim4_15_1_,
todov2list0_.gold as gold5_15_1_,
todov2list0_.is_checked as is_check6_15_1_,
todov2list0_.message as message7_15_1_,
todov2list0_.content_id as content_9_15_1_
from
todov2 todov2list0_
where
todov2list0_.character_id=?
2023-11-24 17:32:29.830 DEBUG 39633 --- [nio-8080-exec-6] org.hibernate.SQL :
select
todov2list0_.character_id as characte8_15_0_,
todov2list0_.todo_id as todo_id1_15_0_,
todov2list0_.todo_id as todo_id1_15_1_,
todov2list0_.created_date as created_2_15_1_,
todov2list0_.last_modified_date as last_mod3_15_1_,
todov2list0_.character_id as characte8_15_1_,
todov2list0_.cool_time as cool_tim4_15_1_,
todov2list0_.gold as gold5_15_1_,
todov2list0_.is_checked as is_check6_15_1_,
todov2list0_.message as message7_15_1_,
todov2list0_.content_id as content_9_15_1_
from
todov2 todov2list0_
where
todov2list0_.character_id=?
2023-11-24 17:32:29.831 DEBUG 39633 --- [nio-8080-exec-6] org.hibernate.SQL :
select
todov2list0_.character_id as characte8_15_0_,
todov2list0_.todo_id as todo_id1_15_0_,
todov2list0_.todo_id as todo_id1_15_1_,
todov2list0_.created_date as created_2_15_1_,
todov2list0_.last_modified_date as last_mod3_15_1_,
todov2list0_.character_id as characte8_15_1_,
todov2list0_.cool_time as cool_tim4_15_1_,
todov2list0_.gold as gold5_15_1_,
todov2list0_.is_checked as is_check6_15_1_,
todov2list0_.message as message7_15_1_,
todov2list0_.content_id as content_9_15_1_
from
todov2 todov2list0_
where
todov2list0_.character_id=?
2023-11-24 17:32:29.831 DEBUG 39633 --- [nio-8080-exec-6] org.hibernate.SQL :
select
todov2list0_.character_id as characte8_15_0_,
todov2list0_.todo_id as todo_id1_15_0_,
todov2list0_.todo_id as todo_id1_15_1_,
todov2list0_.created_date as created_2_15_1_,
todov2list0_.last_modified_date as last_mod3_15_1_,
todov2list0_.character_id as characte8_15_1_,
todov2list0_.cool_time as cool_tim4_15_1_,
todov2list0_.gold as gold5_15_1_,
todov2list0_.is_checked as is_check6_15_1_,
todov2list0_.message as message7_15_1_,
todov2list0_.content_id as content_9_15_1_
from
todov2 todov2list0_
where
todov2list0_.character_id=?
2023-11-24 17:32:29.832 DEBUG 39633 --- [nio-8080-exec-6] org.hibernate.SQL :
select
todov2list0_.character_id as characte8_15_0_,
todov2list0_.todo_id as todo_id1_15_0_,
todov2list0_.todo_id as todo_id1_15_1_,
todov2list0_.created_date as created_2_15_1_,
todov2list0_.last_modified_date as last_mod3_15_1_,
todov2list0_.character_id as characte8_15_1_,
todov2list0_.cool_time as cool_tim4_15_1_,
todov2list0_.gold as gold5_15_1_,
todov2list0_.is_checked as is_check6_15_1_,
todov2list0_.message as message7_15_1_,
todov2list0_.content_id as content_9_15_1_
from
todov2 todov2list0_
where
todov2list0_.character_id=?
2023-11-24 17:32:29.833 DEBUG 39633 --- [nio-8080-exec-6] org.hibernate.SQL :
select
todov2list0_.character_id as characte8_15_0_,
todov2list0_.todo_id as todo_id1_15_0_,
todov2list0_.todo_id as todo_id1_15_1_,
todov2list0_.created_date as created_2_15_1_,
todov2list0_.last_modified_date as last_mod3_15_1_,
todov2list0_.character_id as characte8_15_1_,
todov2list0_.cool_time as cool_tim4_15_1_,
todov2list0_.gold as gold5_15_1_,
todov2list0_.is_checked as is_check6_15_1_,
todov2list0_.message as message7_15_1_,
todov2list0_.content_id as content_9_15_1_
from
todov2 todov2list0_
where
todov2list0_.character_id=?
2023-11-24 17:32:29.834 DEBUG 39633 --- [nio-8080-exec-6] org.hibernate.SQL :
select
todov2list0_.character_id as characte8_15_0_,
todov2list0_.todo_id as todo_id1_15_0_,
todov2list0_.todo_id as todo_id1_15_1_,
todov2list0_.created_date as created_2_15_1_,
todov2list0_.last_modified_date as last_mod3_15_1_,
todov2list0_.character_id as characte8_15_1_,
todov2list0_.cool_time as cool_tim4_15_1_,
todov2list0_.gold as gold5_15_1_,
todov2list0_.is_checked as is_check6_15_1_,
todov2list0_.message as message7_15_1_,
todov2list0_.content_id as content_9_15_1_
from
todov2 todov2list0_
where
todov2list0_.character_id=?
2023-11-24 17:32:29.835 DEBUG 39633 --- [nio-8080-exec-6] org.hibernate.SQL :
select
todov2list0_.character_id as characte8_15_0_,
todov2list0_.todo_id as todo_id1_15_0_,
todov2list0_.todo_id as todo_id1_15_1_,
todov2list0_.created_date as created_2_15_1_,
todov2list0_.last_modified_date as last_mod3_15_1_,
todov2list0_.character_id as characte8_15_1_,
todov2list0_.cool_time as cool_tim4_15_1_,
todov2list0_.gold as gold5_15_1_,
todov2list0_.is_checked as is_check6_15_1_,
todov2list0_.message as message7_15_1_,
todov2list0_.content_id as content_9_15_1_
from
todov2 todov2list0_
where
todov2list0_.character_id=?
2023-11-24 17:32:29.835 DEBUG 39633 --- [nio-8080-exec-6] org.hibernate.SQL :
select
todov2list0_.character_id as characte8_15_0_,
todov2list0_.todo_id as todo_id1_15_0_,
todov2list0_.todo_id as todo_id1_15_1_,
todov2list0_.created_date as created_2_15_1_,
todov2list0_.last_modified_date as last_mod3_15_1_,
todov2list0_.character_id as characte8_15_1_,
todov2list0_.cool_time as cool_tim4_15_1_,
todov2list0_.gold as gold5_15_1_,
todov2list0_.is_checked as is_check6_15_1_,
todov2list0_.message as message7_15_1_,
todov2list0_.content_id as content_9_15_1_
from
todov2 todov2list0_
where
todov2list0_.character_id=?
2023-11-24 17:32:29.837 DEBUG 39633 --- [nio-8080-exec-6] org.hibernate.SQL :
select
todov2list0_.character_id as characte8_15_0_,
todov2list0_.todo_id as todo_id1_15_0_,
todov2list0_.todo_id as todo_id1_15_1_,
todov2list0_.created_date as created_2_15_1_,
todov2list0_.last_modified_date as last_mod3_15_1_,
todov2list0_.character_id as characte8_15_1_,
todov2list0_.cool_time as cool_tim4_15_1_,
todov2list0_.gold as gold5_15_1_,
todov2list0_.is_checked as is_check6_15_1_,
todov2list0_.message as message7_15_1_,
todov2list0_.content_id as content_9_15_1_
from
todov2 todov2list0_
where
todov2list0_.character_id=?
2023-11-24 17:32:29.838 DEBUG 39633 --- [nio-8080-exec-6] org.hibernate.SQL :
select
todov2list0_.character_id as characte8_15_0_,
todov2list0_.todo_id as todo_id1_15_0_,
todov2list0_.todo_id as todo_id1_15_1_,
todov2list0_.created_date as created_2_15_1_,
todov2list0_.last_modified_date as last_mod3_15_1_,
todov2list0_.character_id as characte8_15_1_,
todov2list0_.cool_time as cool_tim4_15_1_,
todov2list0_.gold as gold5_15_1_,
todov2list0_.is_checked as is_check6_15_1_,
todov2list0_.message as message7_15_1_,
todov2list0_.content_id as content_9_15_1_
from
todov2 todov2list0_
where
todov2list0_.character_id=?
여러 테이블을 SELECT 문으로 호출
테이블이 더 늘어나기전에 정리를 해야할 꺼 같아서 정리
2. 개발
2 - 1. 리팩토링 코드
FETCH JOIN으로 묶음
@Query(value = "SELECT DISTINCT c FROM Character c " +
"JOIN FETCH c.todoV2List t JOIN FETCH t.weekContent " +
"JOIN FETCH c.dayTodo.guardian " +
"JOIN FETCH c.dayTodo.chaos " +
"WHERE c.member.username = :username AND c.serverName = :serverName")
List<Character> findCharacterListServerName(@Param("username") String username, @Param("serverName") String serverName);
2 - 2. 리팩토링 결과
select
distinct character0_.characters_id as characte1_0_0_,
todov2list1_.todo_id as todo_id1_15_1_,
weekconten2_.content_id as content_2_4_2_,
daycontent3_.content_id as content_2_4_3_,
daycontent4_.content_id as content_2_4_4_,
character0_.created_date as created_2_0_0_,
character0_.last_modified_date as last_mod3_0_0_,
character0_.challenge_abyss as challeng4_0_0_,
character0_.challenge_guardian as challeng5_0_0_,
character0_.character_class_name as characte6_0_0_,
character0_.character_image as characte7_0_0_,
character0_.character_level as characte8_0_0_,
character0_.character_name as characte9_0_0_,
character0_.chaos_id as chaos_i36_0_0_,
character0_.chaos_check as chaos_c10_0_0_,
character0_.chaos_gauge as chaos_g11_0_0_,
character0_.chaos_gold as chaos_g12_0_0_,
character0_.chaos_name as chaos_n13_0_0_,
character0_.epona_check as epona_c14_0_0_,
character0_.epona_check2 as epona_c15_0_0_,
character0_.epona_gauge as epona_g16_0_0_,
character0_.guardian_id as guardia37_0_0_,
character0_.guardian_check as guardia17_0_0_,
character0_.guardian_gauge as guardia18_0_0_,
character0_.guardian_gold as guardia19_0_0_,
character0_.guardian_name as guardia20_0_0_,
character0_.gold_character as gold_ch21_0_0_,
character0_.item_level as item_le22_0_0_,
character0_.member_id as member_38_0_0_,
character0_.server_name as server_23_0_0_,
character0_.show_chaos as show_ch24_0_0_,
character0_.show_character as show_ch25_0_0_,
character0_.show_cube_ticket as show_cu26_0_0_,
character0_.show_epona as show_ep27_0_0_,
character0_.show_guardian as show_gu28_0_0_,
character0_.show_silmael_change as show_si29_0_0_,
character0_.show_week_epona as show_we30_0_0_,
character0_.show_week_todo as show_we31_0_0_,
character0_.sort_number as sort_nu32_0_0_,
character0_.cube_ticket as cube_ti33_0_0_,
character0_.silmael_change as silmael34_0_0_,
character0_.week_epona as week_ep35_0_0_,
todov2list1_.created_date as created_2_15_1_,
todov2list1_.last_modified_date as last_mod3_15_1_,
todov2list1_.character_id as characte8_15_1_,
todov2list1_.cool_time as cool_tim4_15_1_,
todov2list1_.gold as gold5_15_1_,
todov2list1_.is_checked as is_check6_15_1_,
todov2list1_.message as message7_15_1_,
todov2list1_.content_id as content_9_15_1_,
todov2list1_.character_id as characte8_15_0__,
todov2list1_.todo_id as todo_id1_15_0__,
weekconten2_.category as category3_4_2_,
weekconten2_.level as level4_4_2_,
weekconten2_.name as name5_4_2_,
weekconten2_.cool_time as cool_ti16_4_2_,
weekconten2_.destruction_stone as destruc13_4_2_,
weekconten2_.gate as gate17_4_2_,
weekconten2_.gold as gold18_4_2_,
weekconten2_.guardian_stone as guardia14_4_2_,
weekconten2_.honor_shard as honor_s15_4_2_,
weekconten2_.leap_stone as leap_sto8_4_2_,
weekconten2_.week_category as week_ca19_4_2_,
weekconten2_.week_content_category as week_co20_4_2_,
daycontent3_.category as category3_4_3_,
daycontent3_.level as level4_4_3_,
daycontent3_.name as name5_4_3_,
daycontent3_.destruction_stone as destruc13_4_3_,
daycontent3_.guardian_stone as guardia14_4_3_,
daycontent3_.honor_shard as honor_s15_4_3_,
daycontent3_.jewelry as jewelry7_4_3_,
daycontent3_.leap_stone as leap_sto8_4_3_,
daycontent3_.shilling as shilling9_4_3_,
daycontent4_.category as category3_4_4_,
daycontent4_.level as level4_4_4_,
daycontent4_.name as name5_4_4_,
daycontent4_.destruction_stone as destruc13_4_4_,
daycontent4_.guardian_stone as guardia14_4_4_,
daycontent4_.honor_shard as honor_s15_4_4_,
daycontent4_.jewelry as jewelry7_4_4_,
daycontent4_.leap_stone as leap_sto8_4_4_,
daycontent4_.shilling as shilling9_4_4_
from
characters character0_
inner join
todov2 todov2list1_
on character0_.characters_id=todov2list1_.character_id
inner join
content weekconten2_
on todov2list1_.content_id=weekconten2_.content_id
inner join
content daycontent3_
on character0_.guardian_id=daycontent3_.content_id
inner join
content daycontent4_
on character0_.chaos_id=daycontent4_.content_id cross
join
member member5_
where
character0_.member_id=member5_.member_id
and member5_.username=?
and character0_.server_name=?
3. 정리 및 후기
리팩토링 후 테스트해보니 주간 숙제가 없는 캐릭터 데이터는 못불러와서 다시 롤백...