taehee-kim-dev
@taeheekimdev
Reviews Written
3
Average Rating
5.0
Posts
Q&A
์ํฐํฐ ๋งค๋์ ์ง๋ฌธ๋๋ฆฝ๋๋ค!
ํ์ตํ ์คํธ๋ก ํ์ธ์ ํ์ผ๋ ๋ญ๊ฐ.. ์ํ๋๊ป ํ๋ฒ ๋ ํ์คํ ํ์ธ์ ๋ฐ๊ณ ์ถ์ด์ ๊ทธ๋ฌ์ต๋๋ค!! ใ ใ ใ ๊ฐ์ฌํฉ๋๋ค ๐
- 0
- 2
- 219
Q&A
๋ก๊ทธ์ธ ๊ตฌํ ์ง๋ฌธ๋๋ฆฝ๋๋ค.
์ ๋ง์ ๋ง ๊ฐ์ฌ๋๋ฆฝ๋๋ค!!!!!!!!!
- 1
- 4
- 336
Q&A
๋ก๊ทธ์ธ ๊ตฌํ ์ง๋ฌธ๋๋ฆฝ๋๋ค.
๋ต๋ณ ์ ๋ง ๊ฐ์ฌ๋๋ฆฝ๋๋ค. ๊ฒฐ๊ตญ ์คํ๋ง ์ํ๋ฆฌํฐ์ ๋ก๊ทธ์ธ ์ธ์ฆ์, UserDetailService ๊ตฌํ์ฒด์์ DB์์ ๊ฒ์ํด username, password ๋ฑ์ ์ ๋ณด๋ฅผ ์ฑ์๋ฃ์ด ๋ฐํํ "์คํ๋ง ์ํ๋ฆฌํฐ์ User๊ฐ์ฒด"์ username, password ์ ๋ณด๋ง ๋ณด๊ณ ์ธ์ฆ์ ์งํํ๋๊ฒ ๋ง๋์?
- 1
- 4
- 336
Q&A
@Embedded์ @MappedSuperclass
๋ต๋ณ ๊ฐ์ฌํฉ๋๋ค. ์ ๊ฐ ์ฌ๋ฐ๋ฅด๊ฒ ์ดํดํ๊ณ ์๋ ๊ฑด๊ฐ์?
- 0
- 3
- 322
Q&A
@RequestBody์ @ModelAttribute
์ ์๋๋ค์.. @PathVariable์ ์ฃผ์์ URI๋ก ๋ค์ด์ค์ง๋ง @RequestParam์ POST์์ฒญ์ ๊ฒฝ์ฐ ๋ณธ๋ฌธ์ ๋ค์ด์ค๋๊น.. ๊ฒฐ๊ตญ @ModelAttribute๋ ์์ฒญ ๋งค๊ฐ๋ณ์ํํ(key=value)๋ ์ฟผ๋ฆฌํ๋ผ๋ฏธํฐ๋ ๋ณธ๋ฌธ์ด๋ ๋ชจ๋ ๋งคํ์ด ๋์ง๋ง, JSONํํ๋ ๋งคํ์ด ์๋๋ ๊ฑฐ๊ตฐ์?
- 0
- 4
- 422
Q&A
@RequestBody์ @ModelAttribute
@ModelAtteibute๋ @PathVariable์ด๋ @RequestParam์ผ๋ก ๋ค์ด์ค๋ ๊ฐ๋ค๋ง ๋งคํ์ด ๋ผ์, @RequestBody๋ก ๋ค์ด์ค๋, ์ฆ JSONํํ๋ก ์์ฒญ body ๋ณธ๋ฌธ์ ๋ค์ด์ค๋ ๋ด์ฉ์ ๋งคํ์ ๋ชปํ๋ ๊ฒ ๊ฐ์๋ฐ.. ๋ง๋์??
- 0
- 4
- 422
Q&A
@NamedEntityGraph ์ Fetch
์, ์ ๊ฐ ํ๋๊ฒ์ Notification ์์ฒด๋ฅผ ์กฐํํ๋ ๊ฒ ์ด์์ต๋๋ค. Notification.java @Entity @Getter @Setter @EqualsAndHashCode(of = "id") @NoArgsConstructor public class Notification { @Id @GeneratedValue private Long id; @Enumerated(EnumType.STRING) private NotificationType notificationType; private String title; private String link; private boolean ringBellChecked = false; private boolean linkVisited = false; @ManyToOne private Account account; @ManyToMany private List commonTag = new LinkedList(); private LocalDateTime createdDateTime; } NotificationController.java @RequiredArgsConstructor @Controller public class NotificationController { private final NotificationService notificationService; @GetMapping(ALL_NOTIFICATION_LIST_URL) public String showALLNotificationList(@SessionAccount Account sessionAccount, Model model){ model.addAttribute(SESSION_ACCOUNT, sessionAccount); List allNotification = notificationService.ringBellCheck(sessionAccount); model.addAttribute("allNotification", allNotification); return ALL_NOTIFICATION_LIST_VIEW_NAME; } } ์ฌ๊ธฐ์ @SessionAccount๋ ๊ฐ์์์์ @CurrentUser์ ์ด๋ฆ๋ง ๋ค๋ฅผ ๋ฟ, ๋๋จธ์ง๋ ๊ฐ์ต๋๋ค. NotificationService.java @Transactional @RequiredArgsConstructor @Service public class NotificationService { private final NotificationRepository notificationRepository; public List ringBellCheck(Account sessionAccount) { List allNotification = notificationRepository.findByAccountOrderByCreatedDateTimeDesc(sessionAccount); allNotification.forEach(notification -> notification.setRingBellChecked(true)); return allNotification; } } N+1 select ๋ฌธ์ ํด๊ฒฐ ์ ์ฉ ์ํ ์ํ์ ๋๋ค. ๋๋ฒ๊น ํด๋ดค์ ๋, List allNotification = notificationRepository.findByAccountOrderByCreatedDateTimeDesc(sessionAccount); ์์ 2020-07-29 15:49:42.664 DEBUG 8952 --- [io-8080-exec-10] org.hibernate.SQL : select notificati0_.id as id1_2_, notificati0_.account_id as account_8_2_, notificati0_.created_date_time as created_2_2_, notificati0_.link as link3_2_, notificati0_.link_visited as link_vis4_2_, notificati0_.notification_type as notifica5_2_, notificati0_.ring_bell_checked as ring_bel6_2_, notificati0_.title as title7_2_ from notification notificati0_ where notificati0_.account_id=? order by notificati0_.created_date_time desc 2020-07-29 15:49:42.665 TRACE 8952 --- [io-8080-exec-10] o.h.type.descriptor.sql.BasicBinder : binding parameter [1] as [BIGINT] - [1] 2020-07-29 15:49:42.703 DEBUG 8952 --- [io-8080-exec-10] org.hibernate.SQL : select account0_.id as id1_0_0_, account0_.bio as bio2_0_0_, account0_.count_of_sending_email_verification_email as count_of3_0_0_, account0_.email_first_verified as email_fi4_0_0_, account0_.email_verification_token as email_ve5_0_0_, account0_.email_verified as email_ve6_0_0_, account0_.email_waiting_to_be_verified as email_wa7_0_0_, account0_.first_count_of_sending_email_verification_email_set_date_time as first_co8_0_0_, account0_.location as location9_0_0_, account0_.nickname as nicknam10_0_0_, account0_.nickname_before_update as nicknam11_0_0_, account0_.notification_comment_on_my_comment_by_email as notific12_0_0_, account0_.notification_comment_on_my_comment_by_web as notific13_0_0_, account0_.notification_comment_on_my_post_by_email as notific14_0_0_, account0_.notification_comment_on_my_post_by_web as notific15_0_0_, account0_.notification_like_on_my_comment_by_email as notific16_0_0_, account0_.notification_like_on_my_comment_by_web as notific17_0_0_, account0_.notification_like_on_my_post_by_email as notific18_0_0_, account0_.notification_like_on_my_post_by_web as notific19_0_0_, account0_.notification_my_interest_tag_added_to_existing_post_by_email as notific20_0_0_, account0_.notification_my_interest_tag_added_to_existing_post_by_web as notific21_0_0_, account0_.notification_new_post_with_my_interest_tag_by_email as notific22_0_0_, account0_.notification_new_post_with_my_interest_tag_by_web as notific23_0_0_, account0_.occupation as occupat24_0_0_, account0_.password as passwor25_0_0_, account0_.profile_image as profile26_0_0_, account0_.show_password_update_page_token as show_pa27_0_0_, account0_.sign_up_date_time as sign_up28_0_0_, account0_.user_id as user_id29_0_0_, account0_.verified_email as verifie30_0_0_ from account account0_ where account0_.id=? 2020-07-29 15:49:42.704 TRACE 8952 --- [io-8080-exec-10] o.h.type.descriptor.sql.BasicBinder : binding parameter [1] as [BIGINT] - [1] ์ด์ ๊ฐ์ด Account๋ฅผ ์กฐํํ๋ ์ฟผ๋ฆฌ๋ ๊ฐ์ด ๋ฐ์๋ฉ๋๋ค. ๊ทธ๋ฐ๋ฐ ์ด๋ Notification์ด DB์ 1๊ฐ์ด์ ์กด์ฌํ ๋ ์ด๊ณ , ์กด์ฌํ์ง ์์๋๋ 2020-07-29 15:52:09.195 DEBUG 4604 --- [nio-8080-exec-7] org.hibernate.SQL : select notificati0_.id as id1_2_, notificati0_.account_id as account_8_2_, notificati0_.created_date_time as created_2_2_, notificati0_.link as link3_2_, notificati0_.link_visited as link_vis4_2_, notificati0_.notification_type as notifica5_2_, notificati0_.ring_bell_checked as ring_bel6_2_, notificati0_.title as title7_2_ from notification notificati0_ where notificati0_.account_id=? order by notificati0_.created_date_time desc 2020-07-29 15:52:09.196 TRACE 4604 --- [nio-8080-exec-7] o.h.type.descriptor.sql.BasicBinder : binding parameter [1] as [BIGINT] - [9] ์ด์๊ฐ์ด Account๋ฅผ ์กฐํํ๋ ์ฟผ๋ฆฌ๋ ๋ฐ์ํ์ง ์์์ต๋๋ค. Notification count๋ฅผ ์กฐํํ ๋๋ ๋ง์ํ์ ๊ฒ์ฒ๋ผ Account๋ฅผ ์กฐํํ ํ์๊ฐ ์์ง๋ง, Notification ์์ฒด๋ฅผ ์กฐํํ ๋๋ ์ฐธ์กฐํ๊ณ ์๋ Account๋ ์กฐํํด์ผ ํ๋๊ฑด๊ฐ์? Notification์ด ์กด์ฌํ์ง ์์๋๋ ์ด์ฐจํผ ์กฐํํ Notification์ด ์์ผ๋ Account ์์ฒด๋ฅผ ์กฐํํ์ง ์๋ ๊ฒ ๊ฐ๊ณ .. ๊ทธ๋ฐ๋ฐ ์ฟผ๋ฆฌ๋ฅผ ๋ณด๋ฉด Notification์ ๋ํ select์ฟผ๋ฆฌ๋ฅผ ๋จผ์ ํ๊ณ ๊ทธ ๋ค์์ Account๋ฅผ ์กฐํํ๋ ์ฟผ๋ฆฌ๋ฅผ ๋ ๋ฆฌ๋๋ฐ, Notification์ ๋ํ select์ฟผ๋ฆฌ๋ฅผ ์ผ๋จ ๋ ๋ฆฌ๊ณ ๋ณด๋ Account๊ฐ์ฒด๊ฐ ํ์ํด์ Account๊ฐ์ฒด๋ฅผ ์กฐํํ๋ select์ฟผ๋ฆฌ๋ฅผ ๋ ๋ ๋ฆฌ๋ ๊ฑด๊ฐ์? count์กฐํ๋ Account์กฐํ๋ฅผ ํ์ง ์๋๋ฐ Notification ์์ฒด ์กฐํ๋ ์ Account์กฐํ๋ฅผ ํ๋์ง ๊ถ๊ธํฉ๋๋ค. Notification ๊ด๋ จ ๋๋ ํ ๋ฆฌ Github ์ฃผ์์ ๋๋ค. https://github.com/taehee-kim-dev/portfolio2/tree/master/src/main/java/portfolio2/module/notification
- 0
- 5
- 298
Q&A
@NamedEntityGraph ์ Fetch
๊ฐ์ฌํฉ๋๋ค! ๊ทธ๋ฆฌ๊ณ NotificationInterceptor.java์์ SecurityContextHolder์์ ์ธ์ ๊ฐ์ฒด๋ฅผ ๊บผ๋ด์ ํด๋น ์ธ์ ๊ฐ์ฒด๋ก Notification๋ฅผ ์กฐํํ ๋๋ ์ Account๋ฅผ ์กฐํํ๋ ์ฟผ๋ฆฌ๋ ์๋ ์๊ฐ๋์? SecurityContextHolder์ ์๋ session ๊ฐ์ฒด๋ detached ์ํ์ด๊ณ , NotificationRepository์์ long countByAccountAndChecked(Account account, boolean checked); ๋ก ์กฐํ๋ฅผ ํ ๋, Account๋ฅผ ๊ฐ์ ธ์ค๋ ์ฟผ๋ฆฌ๊ฐ ๋ ์๊ฐ์ผํ์ง ์๋์?? ์ ๊ฐ Service๋จ์์ ๋น์ทํ ํ์์ ์กฐํ๋ฅผ ํ์ ๋๋ Account๊ฐ์ฒด๋ฅผ ์ฐพ๋ ์ฟผ๋ฆฌ๋ฌธ๋ ๊ฐ์ด ๋ ์๊ฐ๊ฑฐ๋ ์..
- 0
- 5
- 298
Q&A
querydsl ์ค์ ๊ด๋ จ ์ง๋ฌธ๋๋ฆฝ๋๋ค.
์ด๊ฑฐ ํด๊ฒฐํ์ จ๋์? ์ ๋ ์ด๊ฒ๋๋ฌธ์ ๋ฏธ์น๊ฒ ๋ค์ ใ
- 1
- 10
- 15K
Q&A
querydsl ๋น๋ ์๋ฌ ์ง๋ฌธ๋๋ฆฝ๋๋ค.
๋ต๋ณ ๊ฐ์ฌํฉ๋๋ค!! ํ์ง๋ง ์๋๋ค์ใ ๊ทธ๋ฅ gradle๊ณผ์ ํธํ์ฑ ๋ฒ๊ทธ์ธ ๊ฒ ๊ฐ์ต๋๋ค ใ
- 0
- 3
- 5.8K




