From 97a4c5861e6ed0732e493540188157b519a68cf4 Mon Sep 17 00:00:00 2001 From: Somin Yun Date: Sun, 3 Mar 2024 17:14:05 +0900 Subject: [PATCH] feat: #10 product entity --- .../java/com/backend/soullive_a/entity/Age.java | 4 ++++ .../com/backend/soullive_a/entity/BrandImage.java | 4 ++++ .../com/backend/soullive_a/entity/Gender.java | 6 +++++- .../com/backend/soullive_a/entity/Product.java | 15 --------------- .../backend/soullive_a/entity/ProductImage.java | 6 +++++- .../java/com/backend/soullive_a/entity/Range.java | 4 ++++ 6 files changed, 22 insertions(+), 17 deletions(-) diff --git a/src/main/java/com/backend/soullive_a/entity/Age.java b/src/main/java/com/backend/soullive_a/entity/Age.java index 1fc4ac9..dea99d9 100644 --- a/src/main/java/com/backend/soullive_a/entity/Age.java +++ b/src/main/java/com/backend/soullive_a/entity/Age.java @@ -23,6 +23,10 @@ public class Age { @Column(name = "AGE_ID") private Long id; + @ManyToOne(fetch = FetchType.LAZY) + @JoinColumn(name = "PRODUCT_ID", nullable = false) + private Product product; + @Enumerated(EnumType.STRING) @Column(name = "AGE_TYPE") private AgeType ageType; diff --git a/src/main/java/com/backend/soullive_a/entity/BrandImage.java b/src/main/java/com/backend/soullive_a/entity/BrandImage.java index 50c56b7..cd3aae9 100644 --- a/src/main/java/com/backend/soullive_a/entity/BrandImage.java +++ b/src/main/java/com/backend/soullive_a/entity/BrandImage.java @@ -22,6 +22,10 @@ public class BrandImage { @Column(name = "BRAND_IMAGE_ID") private Long id; + @ManyToOne(fetch = FetchType.LAZY) + @JoinColumn(name = "PRODUCT_ID", nullable = false) + private Product product; + @Column(name = "BRAND_IMAGE") private String brandImage; } diff --git a/src/main/java/com/backend/soullive_a/entity/Gender.java b/src/main/java/com/backend/soullive_a/entity/Gender.java index e6e3e7f..1c4b297 100644 --- a/src/main/java/com/backend/soullive_a/entity/Gender.java +++ b/src/main/java/com/backend/soullive_a/entity/Gender.java @@ -23,7 +23,11 @@ public class Gender { @Column(name = "GENDER_ID") private Long id; + @ManyToOne(fetch = FetchType.LAZY) + @JoinColumn(name = "PRODUCT_ID", nullable = false) + private Product product; + @Enumerated(EnumType.STRING) - @Column(name = "GENDER") + @Column(name = "GENDER_TYPE") private GenderType gender; } \ No newline at end of file diff --git a/src/main/java/com/backend/soullive_a/entity/Product.java b/src/main/java/com/backend/soullive_a/entity/Product.java index a119c7a..3dab20e 100644 --- a/src/main/java/com/backend/soullive_a/entity/Product.java +++ b/src/main/java/com/backend/soullive_a/entity/Product.java @@ -31,24 +31,9 @@ public class Product { @Column(name = "BRAND", length = 100) private String brand; - @OneToMany(mappedBy = "PRODUCT") - private List brandImages = new ArrayList<>(); - @Column(name = "PRODUCT", length = 100) private String product; @Column(name = "CHARACTERISTIC") private String characteristic; - - @OneToMany(mappedBy = "PRODUCT_IMAGE") - private List productImages = new ArrayList<>(); - - @OneToMany(mappedBy = "GENDER") - private List genders = new ArrayList<>(); - - @OneToMany(mappedBy = "AGE") - private List ages = new ArrayList<>(); - - @OneToMany(mappedBy = "range") - private List ranges = new ArrayList<>(); } diff --git a/src/main/java/com/backend/soullive_a/entity/ProductImage.java b/src/main/java/com/backend/soullive_a/entity/ProductImage.java index 4a3cae9..132e5a4 100644 --- a/src/main/java/com/backend/soullive_a/entity/ProductImage.java +++ b/src/main/java/com/backend/soullive_a/entity/ProductImage.java @@ -19,9 +19,13 @@ public class ProductImage { @Id @GeneratedValue - @Column(name = "PRODUCT_ID") + @Column(name = "PRODUCT_IMAGE_ID") private Long id; + @ManyToOne(fetch = FetchType.LAZY) + @JoinColumn(name = "PRODUCT_ID", nullable = false) + private Product product; + @Column(name = "PRODUCT_IMAGE") private String productImage; } \ No newline at end of file diff --git a/src/main/java/com/backend/soullive_a/entity/Range.java b/src/main/java/com/backend/soullive_a/entity/Range.java index 42809bd..4abd1a9 100644 --- a/src/main/java/com/backend/soullive_a/entity/Range.java +++ b/src/main/java/com/backend/soullive_a/entity/Range.java @@ -21,6 +21,10 @@ public class Range { @Column(name = "RANGE_ID") private Long id; + @ManyToOne(fetch = FetchType.LAZY) + @JoinColumn(name = "PRODUCT_ID", nullable = false) + private Product product; + @Column(name = "RANGE") private String rangeType; }