Skip to content
Open
Changes from all commits
Commits
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 @@ -26,7 +26,7 @@ public void batchDeleteAllWithExamApplications(List<ApplicationJpaEntity> entiti
.map(ApplicationJpaEntity::getId)
.toList();

String deleteExamApplicationSql = "DELETE FROM exam_application WHERE application_id IN (:applicationIds)";
String deleteExamApplicationSql = "UPDATE exam_application SET deleted = true WHERE application_id IN (:applicationIds)";

Choose a reason for hiding this comment

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

high

exam_application 테이블에 대해 soft delete를 적용하도록 수정되었지만, 이어서 실행되는 코드(33행)에서는 application 테이블의 데이터를 물리적으로 삭제(hard delete)하고 있습니다. 이 경우, 부모 테이블인 application의 데이터가 사라져 exam_application에 남은 데이터가 고아 레코드(orphaned record)가 되어 데이터 정합성에 문제가 발생할 수 있습니다. PR의 본래 목적인 데이터 보존을 위해서는 application 테이블에 대해서도 일관되게 soft delete를 적용하는 것을 강력히 권장합니다.

Choose a reason for hiding this comment

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

medium

쿼리가 DELETE에서 UPDATE로 변경되었으므로, 변수명 deleteExamApplicationSql이 더 이상 코드의 동작을 정확하게 나타내지 않습니다. softDeleteExamApplicationSql과 같이 변수명을 수정하여 코드의 가독성을 높이고 의도를 명확히 하는 것이 좋겠습니다. 이 변수명을 수정할 경우, 30행에서 이 변수를 사용하는 부분도 함께 수정해야 합니다.

namedParameterJdbcTemplate.update(deleteExamApplicationSql,
new MapSqlParameterSource("applicationIds", applicationIds));

Expand Down
Loading