Classe mercado
`
package br.com.fractal.mercado.entity;
import java.io.Serializable;
import java.util.List;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.OneToMany;
import javax.persistence.PrimaryKeyJoinColumn;
import javax.persistence.Table;
@Entity
@Table(name = "mercado")
public class Mercado implements Serializable {
private static final long serialVersionUID = 3651127774133107117L;
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name = "id_merc")
private Integer id;
@Column(name = "cnpj_merc", nullable = true)
private String cnpj;
@Column(name = "nome_fantasia_merc", nullable = true)
private String nomeFantasia;
@Column(name = "nome_merc", nullable = true)
private String nome;
@Column(name = "end_merc", nullable = true)
private String end;
@Column(name = "bairro_merc", nullable = true)
private String bairro;
@Column(name = "cep_merc", nullable = true)
private String cep;
@Column(name = "tel_merc", nullable = true)
private String telefone;
@Column(name = "whatzap_merc", nullable = true)
private String whatsapp;
@Column(name = "email_merc", nullable = true)
private String email;
@Column(name = "ativo", nullable = true)
private Boolean ativo;
@Column(name = "logo_merc", nullable = true)
private String logo;
@OneToMany(fetch = FetchType.EAGER,cascade = CascadeType.ALL)
@Column(name="id_catpro", insertable = true)
private List<Categoria> categorias;
public Integer getId() {
return id;
}
public void setId(Integer id) {
this.id = id;
}
public String getCnpj() {
return cnpj;
}
public void setCnpj(String cnpj) {
this.cnpj = cnpj;
}
public String getNomeFantasia() {
return nomeFantasia;
}
public void setNomeFantasia(String nomeFantasia) {
this.nomeFantasia = nomeFantasia;
}
public String getNome() {
return nome;
}
public void setNome(String nome) {
this.nome = nome;
}
public String getEnd() {
return end;
}
public void setEnd(String end) {
this.end = end;
}
public String getBairro() {
return bairro;
}
public void setBairro(String bairro) {
this.bairro = bairro;
}
public String getCep() {
return cep;
}
public void setCep(String cep) {
this.cep = cep;
}
public String getTelefone() {
return telefone;
}
public void setTelefone(String telefone) {
this.telefone = telefone;
}
public String getWhatsapp() {
return whatsapp;
}
public void setWhatsapp(String whatsapp) {
this.whatsapp = whatsapp;
}
public String getEmail() {
return email;
}
public void setEmail(String email) {
this.email = email;
}
public Boolean getAtivo() {
return ativo;
}
public void setAtivo(Boolean ativo) {
this.ativo = ativo;
}
public String getLogo() {
return logo;
}
public void setLogo(String logo) {
this.logo = logo;
}
public List<Categoria> getCategorias() {
return categorias;
}
public void setCategorias(List<Categoria> categorias) {
this.categorias = categorias;
}
@Override
public int hashCode() {
final int prime = 31;
int result = 1;
result = prime * result + ((id == null) ? 0 : id.hashCode());
return result;
}
@Override
public boolean equals(Object obj) {
if (this == obj)
return true;
if (obj == null)
return false;
if (getClass() != obj.getClass())
return false;
Mercado other = (Mercado) obj;
if (id == null) {
if (other.id != null)
return false;
} else if (!id.equals(other.id))
return false;
return true;
}
}