package com.mousetech.gourmetj.persistence.model; import java.io.Serializable; import java.util.ArrayList; import java.util.List; import jakarta.persistence.Column; import jakarta.persistence.Entity; import jakarta.persistence.FetchType; import jakarta.persistence.GeneratedValue; import jakarta.persistence.GenerationType; import jakarta.persistence.Id; import jakarta.persistence.ManyToOne; import jakarta.persistence.NamedQueries; import jakarta.persistence.NamedQuery; import jakarta.persistence.OneToMany; import jakarta.persistence.Table; /** * The persistent class for the "shopcats" database table. * * Properly, a Shopcat should be an optional ManyToOne reference * from Ingredient, but the database schema does not rigorously * enforce that. To do so, Ingredient.ingKey would be formally * declared as a foreign key and in Shopcat.ingKey would be declared * as a unique key (and could serve as primary key). * * Failing that, crud can accumulate in the database and it's * mostly dealt with in the @see ReceipeDAO. * */ @Entity @Table(name = "shopcats") public class Shopcat implements Serializable { private static final long serialVersionUID = 1L; @Id @GeneratedValue(strategy = GenerationType.IDENTITY) @Column(name = "id") private Long id; @Column(name = "ingkey", unique = true, nullable = false ) private String ingkey; @OneToMany(fetch = FetchType.LAZY, mappedBy = "ingkey" ) private List ingredients; /** * @return the ingredients */ public List getIngredients() { return ingredients; } /** * @param ingredients the ingredients to set */ public void setIngredients(List ingredient) { this.ingredients = ingredient; } @Column(name = "position") private Integer position; @Column(name = "shopcategory") private String shopcategory; public Shopcat() { } public Long getId() { return this.id; } public void setId(Long id) { this.id = id; } /** * @return the ingkey */ public String getIngkey() { return ingkey; } /** * @param ingkey the ingkey to set */ public void setIngkey(String ingkey) { this.ingkey = ingkey; } public Integer getPosition() { return this.position; } public void setPosition(Integer position) { this.position = position; } public String getShopcategory() { return this.shopcategory; } public void setShopcategory(String shopcategory) { this.shopcategory = shopcategory; } @Override public String toString() { return "Shopcat for " + "(" + shopcategory + ")"; } }