diff --git a/src/main/java/com/kakaoteck/golagola/domain/order/entity/Order.java b/src/main/java/com/kakaoteck/golagola/domain/order/entity/Order.java index 55fafb4..1a5b297 100644 --- a/src/main/java/com/kakaoteck/golagola/domain/order/entity/Order.java +++ b/src/main/java/com/kakaoteck/golagola/domain/order/entity/Order.java @@ -1,6 +1,7 @@ package com.kakaoteck.golagola.domain.order.entity; import com.kakaoteck.golagola.domain.buyer.entity.Buyer; +import com.kakaoteck.golagola.domain.orderProduct.entity.OrderProduct; import com.kakaoteck.golagola.domain.seller.entity.Seller; import com.kakaoteck.golagola.global.common.BaseEntity; import com.kakaoteck.golagola.global.common.enums.OrderStatus; @@ -11,6 +12,7 @@ import lombok.NoArgsConstructor; import java.time.LocalDate; +import java.util.List; @Entity @NoArgsConstructor @@ -32,6 +34,9 @@ public class Order extends BaseEntity { @JoinColumn(name = "buyer_id") private Buyer buyer; + @OneToMany(mappedBy = "order", cascade = CascadeType.ALL) + private List orderProductList; + private boolean isPay; private LocalDate paymentDate; private String orderAddress; diff --git a/src/main/java/com/kakaoteck/golagola/domain/orderProduct/entity/OrderProduct.java b/src/main/java/com/kakaoteck/golagola/domain/orderProduct/entity/OrderProduct.java index 0efa3f1..43591b6 100644 --- a/src/main/java/com/kakaoteck/golagola/domain/orderProduct/entity/OrderProduct.java +++ b/src/main/java/com/kakaoteck/golagola/domain/orderProduct/entity/OrderProduct.java @@ -1,5 +1,6 @@ package com.kakaoteck.golagola.domain.orderProduct.entity; +import com.kakaoteck.golagola.domain.order.entity.Order; import com.kakaoteck.golagola.domain.product.entity.Product; import com.kakaoteck.golagola.domain.review.entity.Review; import jakarta.persistence.*; @@ -24,6 +25,10 @@ public class OrderProduct { @JoinColumn(name = "product_id") private Product product; + @ManyToOne(fetch = FetchType.LAZY) + @JoinColumn(name = "order_id") + private Order order; + @OneToOne(mappedBy = "orderProduct", cascade = CascadeType.ALL) private Review review;