You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
//@BatchSize Annotation 사용 시publicList<ItemResWithTag> getAllItem(LonguserId){
//Select ItemList<Item> itemList = itemRepository.findItemsByUserId(userId);
//Select Tags//getter 호출 로, 영속성에 포함된 모든 item 의 List<Tag> 초기화System.out.println(folderList.get(0).getTags());
//Item -> ItemResWithTag 로 변환/* ... return ...; */
}
BatchSize 기능 직접 구현
publicList<ItemResWithTag> getAllItem(LonguserId){
//Select ItemResList<ItemRes> itemList = itemRepository.findItemsByUserId(userId);
//Select Tags// ItemPK로 Item과 Tag가 연결되어있다고 가정// 1. where 절에 담을 Item 의 PK값들 추출// 2. tagRepository 에서 in 절로 호출하여 모두 가져옴// 3. 가져온 tag 들을 ItemRes -> ItemResWithTag 로 변환하면서 연결 /* var ... = itemList.stream().map(ItemRes::getItemPk).collect(Colletors.toSet()); var ... = tagRepoisotry.getTagsByItemPkIn(ItemPkList); .... return ...; */
}
The text was updated successfully, but these errors were encountered:
JPA를 처음 쓸때 접했던 이슈이자, 잘 알려진 유명한 이슈.
잘 알려진 해결 방법으로는 FetchJoin(=EntityGraph) 와 BatchSize가 있다.
잘 알려진 해결방법
필자가 선호하는 방법 (더 나은 방법 찾을 시, 계속 업데이트)
@batchsize 사용과 직접 구현시 코드 비교
@batchsize 사용
BatchSize 기능 직접 구현
The text was updated successfully, but these errors were encountered: