Skip to content
Snippets Groups Projects
Commit 4913be0c authored by Stian Lyng's avatar Stian Lyng
Browse files

add many to many relationships

parent 0d5cc4ab
No related branches found
No related tags found
No related merge requests found
package ntnu.idatt2016.v233.SmartMat.entity;
import java.util.List;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import jakarta.persistence.*;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import ntnu.idatt2016.v233.SmartMat.entity.product.Product;
/**
* Recipe is an entity class representing a recipe in the system.
*
* @author Anders
* @author Anders & Stian
* @version 1.0.001
* @since 19.04.2023
*
......@@ -31,4 +36,12 @@ public class Recipe {
@Column(name = "recipe_description")
String description;
@ManyToMany
@JoinTable(name = "recipe_product",
joinColumns = @JoinColumn(name = "recipe_id"),
inverseJoinColumns = @JoinColumn(name = "ean"))
@JsonIgnoreProperties({"recipes"})
List<Product> products;
}
......@@ -8,6 +8,7 @@ import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import ntnu.idatt2016.v233.SmartMat.entity.Fridge;
import ntnu.idatt2016.v233.SmartMat.entity.Recipe;
import java.util.List;
......@@ -64,4 +65,9 @@ public class Product{
@ManyToMany(mappedBy = "products")
@JsonIgnoreProperties({"products"})
List<Fridge> fridges;
@ManyToMany(mappedBy = "products")
@JsonIgnoreProperties({"products"})
List<Recipe> recipes;
}
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment