From fad041e19d72562f6079db55ae8b4354cf904019 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EA=B6=8C=EC=A3=BC=EC=84=B1?= <99165624+JoosungKwon@users.noreply.github.com> Date: Wed, 17 May 2023 20:24:50 +0900 Subject: [PATCH] =?UTF-8?q?[#221]=20Store=EB=82=B4=20=EB=B3=91=EB=AA=A9=20?= =?UTF-8?q?=ED=98=84=EC=83=81=EC=9D=84=20=EC=9C=A0=EB=B0=9C=ED=95=98?= =?UTF-8?q?=EB=8A=94=20=EC=BD=94=EB=93=9C=20=EC=A0=9C=EA=B1=B0=20(#223)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Store를 Update 하는 과정에서 Point 객체의 값이 미묘하게 변하게 되어 더티체킹으로 Update 쿼리가 나가는 현상이 발생함 - 부하 테스트를 통해 문제를 발견했으며, 이를 @DynamicUpdate와 Objects.equals 비교를 통해 같은 값이면 현재 값을 사용할 수 있도록 함 --- .../com/prgrms/mukvengers/domain/store/model/Store.java | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/prgrms/mukvengers/domain/store/model/Store.java b/src/main/java/com/prgrms/mukvengers/domain/store/model/Store.java index d0bbdeca..69a0b32d 100644 --- a/src/main/java/com/prgrms/mukvengers/domain/store/model/Store.java +++ b/src/main/java/com/prgrms/mukvengers/domain/store/model/Store.java @@ -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; @@ -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 { @@ -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; }