package miage.ecom.entity; import java.io.Serializable; import java.util.Collection; import javax.persistence.Basic; import javax.persistence.CascadeType; import javax.persistence.Column; import javax.persistence.Entity; import javax.persistence.GeneratedValue; import javax.persistence.GenerationType; import javax.persistence.Id; import javax.persistence.JoinColumn; import javax.persistence.JoinTable; import javax.persistence.ManyToOne; import javax.persistence.NamedQueries; import javax.persistence.NamedQuery; import javax.persistence.OneToMany; import javax.persistence.Table; import javax.validation.constraints.Size; import javax.xml.bind.annotation.XmlRootElement; import javax.xml.bind.annotation.XmlTransient; /** * * @author Lou */ @Entity @Table(name = "store") @XmlRootElement @NamedQueries({ @NamedQuery(name = "Store.findAll", query = "SELECT s FROM Store s"), @NamedQuery(name = "Store.findByIdStore", query = "SELECT s FROM Store s WHERE s.idStore = :idStore"), @NamedQuery(name = "Store.findByName", query = "SELECT s FROM Store s WHERE s.name = :name") }) public class Store implements Serializable { private static final long serialVersionUID = 1L; @Id @GeneratedValue(strategy = GenerationType.IDENTITY) @Basic(optional = false) @Column(name = "id_store", unique = true, nullable = false) private Integer idStore; @Size(max = 200) @Column(name = "name") private String name; @JoinColumn(name = "id_account", referencedColumnName = "id_account") @ManyToOne(optional = false) private Account account; @JoinColumn(name = "id_status", referencedColumnName = "id_status") @ManyToOne(optional = false) private Status idStatus; @OneToMany(cascade= CascadeType.ALL, mappedBy = "store") private Collection<StoreHasProduct> storeHasProductsCollection; public Store() { } public Store(Integer idStore) { this.idStore = idStore; } public Integer getIdStore() { return idStore; } public void setIdStore(Integer idStore) { this.idStore = idStore; } public String getName() { return name; } public void setName(String name) { this.name = name; } public Account getAccount() { return account; } public void setAccount(Account account) { this.account = account; } public Status getIdStatus() { return idStatus; } public void setIdStatus(Status idStatus) { this.idStatus = idStatus; } @XmlTransient public Collection<StoreHasProduct> getStoreHasProductsCollection() { return storeHasProductsCollection; } public void setStoreHasProductsCollection(Collection<StoreHasProduct> storeHasProductsCollection) { this.storeHasProductsCollection = storeHasProductsCollection; } @Override public int hashCode() { int hash = 0; hash += (idStore != null ? idStore.hashCode() : 0); return hash; } @Override public boolean equals(Object object) { // TODO: Warning - this method won't work in the case the id fields are not set if (!(object instanceof Store)) { return false; } Store other = (Store) object; if ((this.idStore == null && other.idStore != null) || (this.idStore != null && !this.idStore.equals(other.idStore))) { return false; } return true; } @Override public String toString() { return "miage.ecom.entity.Store[ idStore=" + idStore + " ]"; } }