-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* feat: 하이라이트 벌크 삽입 추가 * refactor: 불필요한 `@Repository` 제거 * fix: `findAll` 사용하지 않도록 수정 * fix: 테스트 수정 * refactor: `NamedParameterJdbcTemplate` 사용하도록 수정
- Loading branch information
Showing
5 changed files
with
58 additions
and
3 deletions.
There are no files selected for viewing
9 changes: 9 additions & 0 deletions
9
backend/src/main/java/reviewme/highlight/repository/HighlightJdbcRepository.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
package reviewme.highlight.repository; | ||
|
||
import java.util.Collection; | ||
import reviewme.highlight.domain.Highlight; | ||
|
||
public interface HighlightJdbcRepository { | ||
|
||
void saveAll(Collection<Highlight> highlights); | ||
} |
24 changes: 24 additions & 0 deletions
24
backend/src/main/java/reviewme/highlight/repository/HighlightJdbcRepositoryImpl.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
package reviewme.highlight.repository; | ||
|
||
import java.util.Collection; | ||
import lombok.RequiredArgsConstructor; | ||
import org.springframework.jdbc.core.namedparam.NamedParameterJdbcTemplate; | ||
import org.springframework.jdbc.core.namedparam.SqlParameterSource; | ||
import org.springframework.jdbc.core.namedparam.SqlParameterSourceUtils; | ||
import reviewme.highlight.domain.Highlight; | ||
|
||
@RequiredArgsConstructor | ||
public class HighlightJdbcRepositoryImpl implements HighlightJdbcRepository { | ||
|
||
private final NamedParameterJdbcTemplate namedParameterJdbcTemplate; | ||
|
||
@Override | ||
public void saveAll(Collection<Highlight> highlights) { | ||
SqlParameterSource[] parameterSources = SqlParameterSourceUtils.createBatch(highlights.toArray()); | ||
String insertSql = """ | ||
INSERT INTO highlight (answer_id, line_index, start_index, end_index) | ||
VALUES (:answerId, :lineIndex, :highlightRange.startIndex, :highlightRange.endIndex) | ||
"""; | ||
namedParameterJdbcTemplate.batchUpdate(insertSql, parameterSources); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters