Skip to content

Commit

Permalink
[#221] Store내 병목 현상을 유발하는 코드 제거 (#223)
Browse files Browse the repository at this point in the history
- Store를 Update 하는 과정에서 Point 객체의 값이 미묘하게 변하게 되어 더티체킹으로 Update 쿼리가 나가는 현상이 발생함
- 부하 테스트를 통해 문제를 발견했으며, 이를 @DynamicUpdate와 Objects.equals 비교를 통해 같은 값이면 현재 값을 사용할 수 있도록 함
  • Loading branch information
JoosungKwon authored May 17, 2023
1 parent 5109f2b commit fad041e
Showing 1 changed file with 8 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,14 @@
import static lombok.AccessLevel.*;
import static org.springframework.util.Assert.*;

import java.util.Objects;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;

import org.hibernate.annotations.DynamicUpdate;
import org.hibernate.annotations.SQLDelete;
import org.hibernate.annotations.Where;
import org.locationtech.jts.geom.Point;
Expand All @@ -24,6 +27,7 @@
@Getter
@NoArgsConstructor(access = PROTECTED)
@Where(clause = "deleted = false")
@DynamicUpdate
@SQLDelete(sql = "UPDATE store set deleted = true where id=?")
public class Store extends BaseEntity {

Expand Down Expand Up @@ -86,9 +90,12 @@ public void updateStore(Store store) {
private Point validatePosition(Point location) {
notNull(location, "유효하지 않는 위치입니다.");

if (Objects.equals(this.location, location)) {
return this.location;
}

validateLongitude(location);
validateLatitude(location);

return location;
}

Expand Down

0 comments on commit fad041e

Please sign in to comment.