Skip to content
Snippets Groups Projects
Commit 8ba757e6 authored by Birk Øvstetun Narvhus's avatar Birk Øvstetun Narvhus
Browse files

hot fixed product frige asso and product, to fix json mappign

parent 8fd5fcaa
No related branches found
No related tags found
No related merge requests found
package ntnu.idatt2016.v233.SmartMat.entity.fridgeProduct; package ntnu.idatt2016.v233.SmartMat.entity.fridgeProduct;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import jakarta.persistence.*; import jakarta.persistence.*;
import lombok.AllArgsConstructor; import lombok.AllArgsConstructor;
import lombok.Builder; import lombok.Builder;
...@@ -21,12 +22,14 @@ public class FridgeProductAsso { ...@@ -21,12 +22,14 @@ public class FridgeProductAsso {
@ManyToOne @ManyToOne
@MapsId("fridge_id") @MapsId("fridge_id")
@JoinColumn(name = "fridge_id") @JoinColumn(name = "fridge_id")
@JsonIgnoreProperties({"products"})
private Fridge fridgeId; private Fridge fridgeId;
@Id @Id
@ManyToOne @ManyToOne
@MapsId("ean") @MapsId("ean")
@JoinColumn(name = "ean") @JoinColumn(name = "ean")
@JsonIgnoreProperties({"fridges"})
private Product ean; private Product ean;
@Id @Id
......
package ntnu.idatt2016.v233.SmartMat.entity.product; package ntnu.idatt2016.v233.SmartMat.entity.product;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import jakarta.persistence.*; import jakarta.persistence.*;
import lombok.AllArgsConstructor; import lombok.AllArgsConstructor;
...@@ -57,7 +58,7 @@ public class Product{ ...@@ -57,7 +58,7 @@ public class Product{
Double amount; Double amount;
@ManyToMany @ManyToMany
@JsonIgnoreProperties({"products"}) @JsonIgnoreProperties({"products", "users"})
@JoinTable( @JoinTable(
name = "product_allergy", name = "product_allergy",
joinColumns = @JoinColumn(name = "ean"), joinColumns = @JoinColumn(name = "ean"),
...@@ -67,10 +68,12 @@ public class Product{ ...@@ -67,10 +68,12 @@ public class Product{
@OneToMany @OneToMany
@JoinColumn(name = "ean") @JoinColumn(name = "ean")
@JsonIgnoreProperties({"products"}) @JsonIgnoreProperties({"products"})
@JsonIgnore
List<FridgeProductAsso> fridges; List<FridgeProductAsso> fridges;
@ManyToMany(mappedBy = "products") @ManyToMany(mappedBy = "products")
@JsonIgnoreProperties({"products"}) @JsonIgnoreProperties({"products"})
@JsonIgnore
List<Recipe> recipes; List<Recipe> recipes;
/** /**
...@@ -84,4 +87,9 @@ public class Product{ ...@@ -84,4 +87,9 @@ public class Product{
fridges.add(fridge); fridges.add(fridge);
} }
@Override
public String toString(){
return String.valueOf(this.ean);
}
} }
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment