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

Merge branch 'Epic/1-product-endpoint' into 'main'

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

See merge request idatt2106-v23-03/backend!117
parents 4f34320f 8ba757e6
No related branches found
No related tags found
No related merge requests found
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
......
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
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