Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BE] Refactor/#430 핀 복사 시 JdbcTemplate을 이용하여 bulk insert하도록 변경 #617

Merged
merged 25 commits into from
Nov 6, 2023
Merged
Changes from 1 commit
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
ca47a30
feat: batch update 적용 중
yoondgu Oct 18, 2023
11f64ff
chore: batch update 적용 중
yoondgu Oct 18, 2023
331db76
feat: pin image를 고려한 batch update 적용
yoondgu Oct 24, 2023
2486358
feat: batch update 시 pinImage N+1 문제 해결을 위한 fetch join
yoondgu Oct 26, 2023
79dcbce
refactor: PinBatchRepository 중복 제거 및 메서드 분리
yoondgu Oct 26, 2023
12ab047
refactor: jdbcTemplate 사용하는 리포지토리를 사용자 정의 리포지토리로 추상화
yoondgu Oct 31, 2023
974de2b
refactor: PinBatchRepository 인덴트 개선
yoondgu Oct 31, 2023
5186cc8
refactor: 테스트 컨테이너 jdbcURl에 batch update를 위한 설정 추가
yoondgu Oct 31, 2023
e6a30ba
refactor: saveAllToTopic 불필요한 인자 제거로 인한 시그니처 변경
yoondgu Nov 1, 2023
60cab90
refactor: 사용자 정의 리포지토리의 saveAllToTopic 테스트 작성
yoondgu Nov 1, 2023
dc9a5b7
refactor: jdbcTemplate, hibernate 중복 로그 하는 대신 커스텀 로그 설정
yoondgu Nov 1, 2023
f907795
test: 테스트 내 불필요한 출력 삭제
yoondgu Nov 1, 2023
26db14d
test: JPA 쿼리 호출과 JdbcTemplate 쿼리 호출 분리
yoondgu Nov 1, 2023
585e135
chore: batch update를 위한 jdbc url 설정 추가
yoondgu Nov 1, 2023
7512b63
chore: 로컬 환경 batch update 설정 추가
yoondgu Nov 1, 2023
0073ed2
refactor: 불필요한 flush 삭제
yoondgu Nov 1, 2023
a57a16c
refactor: 개행 추가
yoondgu Nov 1, 2023
de403b5
chore: 커스텀 리포지토리 패키지 컨텍스트 별로 변경
yoondgu Nov 2, 2023
58fc4ea
refactor: 메서드명 수정 및 가독성 개선
yoondgu Nov 2, 2023
ab519fb
refactor: 불필요한 flush 삭제
yoondgu Nov 3, 2023
eabc420
refactor: rowCount 상태코드 상수화
yoondgu Nov 3, 2023
bd7f38c
refactor: sql 문자열 개행 방식 수정
yoondgu Nov 3, 2023
6976452
refactor: DB용 Dto record로 변경
yoondgu Nov 3, 2023
bda1f24
refactor: 사용하지 않는 메서드 삭제
yoondgu Nov 3, 2023
986ffb1
refactor: 불필요한 update 호출 삭제
yoondgu Nov 3, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -105,10 +105,10 @@ private int[] bulkInsertPinImages(List<PinImageInsertDto> pinImages) {
@Override
public void setValues(PreparedStatement ps, int i) throws SQLException {
PinImageInsertDto pinImage = pinImages.get(i);
ps.setString(1, pinImage.getImageUrl());
ps.setLong(2, pinImage.getPinId());
ps.setString(1, pinImage.imageUrl);
ps.setLong(2, pinImage.pinId);
log.trace("[Parameter Binding] {} : imageUrl={}, pinImage={} ",
i, pinImage.getImageUrl(), pinImage.getPinId());
i, pinImage.imageUrl, pinImage.pinId);
}

@Override
Expand All @@ -118,17 +118,11 @@ public int getBatchSize() {
});
}

private static class PinImageInsertDto {

private final String imageUrl;
private final Long pinId;
private final boolean isDeleted;

private PinImageInsertDto(String imageUrl, Long pinId, boolean isDeleted) {
this.imageUrl = imageUrl;
this.pinId = pinId;
this.isDeleted = isDeleted;
}
private record PinImageInsertDto(
String imageUrl,
Long pinId,
boolean isDeleted
) {
Comment on lines +121 to +125
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 반영해주셔서 감사합니다~!


public static PinImageInsertDto of(PinImage pinImage, Long pinId) {
return new PinImageInsertDto(
Expand All @@ -143,18 +137,6 @@ private static List<PinImageInsertDto> of(List<PinImage> pinImages, Long pinId)
.map(pinImage -> PinImageInsertDto.of(pinImage, pinId))
.toList();
}

public String getImageUrl() {
return imageUrl;
}

public Long getPinId() {
return pinId;
}

public boolean isDeleted() {
return isDeleted;
}
}

}