Skip to content

Commit

Permalink
feat(Product): 상품 구매 동시성 처리를 위한 Product Entity version 필드 추가 (낙관적 락 적용)
Browse files Browse the repository at this point in the history
  • Loading branch information
zzzzseong committed Jan 31, 2024
1 parent ba79adf commit 5ede692
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/main/java/com/sportsecho/product/entity/Product.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import jakarta.persistence.Id;
import jakarta.persistence.OneToMany;
import jakarta.persistence.OneToOne;
import jakarta.persistence.Version;
import java.util.ArrayList;
import java.util.List;
import lombok.AccessLevel;
Expand Down Expand Up @@ -42,13 +43,16 @@ public class Product extends TimeStamp {
@Column(name = "quantity", nullable = false)
private int quantity;

@Version
private Long version;

@OneToMany(mappedBy = "product", fetch = FetchType.LAZY, cascade = CascadeType.ALL, orphanRemoval = true)
private final List<PurchaseProduct> PurchaseProductList = new ArrayList<>();

@OneToMany(mappedBy = "product", fetch = FetchType.LAZY, cascade = CascadeType.ALL, orphanRemoval = true)
private final List<MemberProduct> memberProductList = new ArrayList<>();

@BatchSize(size = 20)
@BatchSize(size = 32)
@OneToMany(mappedBy = "product", fetch = FetchType.LAZY, cascade = CascadeType.ALL, orphanRemoval = true)
private final List<ProductImage> productImageList = new ArrayList<>();

Expand Down

0 comments on commit 5ede692

Please sign in to comment.