From 8ba757e62b951c4427c6ca8bdcdff074f0b0b188 Mon Sep 17 00:00:00 2001 From: birkon <birkon@stud.ntnu.no> Date: Wed, 26 Apr 2023 11:16:28 +0200 Subject: [PATCH] hot fixed product frige asso and product, to fix json mappign --- .../entity/fridgeProduct/FridgeProductAsso.java | 3 +++ .../v233/SmartMat/entity/product/Product.java | 10 +++++++++- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/src/main/java/ntnu/idatt2016/v233/SmartMat/entity/fridgeProduct/FridgeProductAsso.java b/src/main/java/ntnu/idatt2016/v233/SmartMat/entity/fridgeProduct/FridgeProductAsso.java index 55dce18f..14a3415a 100644 --- a/src/main/java/ntnu/idatt2016/v233/SmartMat/entity/fridgeProduct/FridgeProductAsso.java +++ b/src/main/java/ntnu/idatt2016/v233/SmartMat/entity/fridgeProduct/FridgeProductAsso.java @@ -1,5 +1,6 @@ package ntnu.idatt2016.v233.SmartMat.entity.fridgeProduct; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import jakarta.persistence.*; import lombok.AllArgsConstructor; import lombok.Builder; @@ -21,12 +22,14 @@ public class FridgeProductAsso { @ManyToOne @MapsId("fridge_id") @JoinColumn(name = "fridge_id") + @JsonIgnoreProperties({"products"}) private Fridge fridgeId; @Id @ManyToOne @MapsId("ean") @JoinColumn(name = "ean") + @JsonIgnoreProperties({"fridges"}) private Product ean; @Id diff --git a/src/main/java/ntnu/idatt2016/v233/SmartMat/entity/product/Product.java b/src/main/java/ntnu/idatt2016/v233/SmartMat/entity/product/Product.java index ba2a2a1e..a4b53328 100644 --- a/src/main/java/ntnu/idatt2016/v233/SmartMat/entity/product/Product.java +++ b/src/main/java/ntnu/idatt2016/v233/SmartMat/entity/product/Product.java @@ -1,5 +1,6 @@ package ntnu.idatt2016.v233.SmartMat.entity.product; +import com.fasterxml.jackson.annotation.JsonIgnore; import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import jakarta.persistence.*; import lombok.AllArgsConstructor; @@ -57,7 +58,7 @@ public class Product{ Double amount; @ManyToMany - @JsonIgnoreProperties({"products"}) + @JsonIgnoreProperties({"products", "users"}) @JoinTable( name = "product_allergy", joinColumns = @JoinColumn(name = "ean"), @@ -67,10 +68,12 @@ public class Product{ @OneToMany @JoinColumn(name = "ean") @JsonIgnoreProperties({"products"}) + @JsonIgnore List<FridgeProductAsso> fridges; @ManyToMany(mappedBy = "products") @JsonIgnoreProperties({"products"}) + @JsonIgnore List<Recipe> recipes; /** @@ -84,4 +87,9 @@ public class Product{ fridges.add(fridge); } + + @Override + public String toString(){ + return String.valueOf(this.ean); + } } \ No newline at end of file -- GitLab