package audit.teste.model; import audit.Auditable; import java.io.Serializable; import java.util.HashSet; import java.util.Set; import javax.persistence.CascadeType; import javax.persistence.Entity; import javax.persistence.GeneratedValue; import javax.persistence.GenerationType; import javax.persistence.Id; import javax.persistence.OneToMany; @Entity @javax.persistence.SequenceGenerator(name="SEQ_ENTIDADE", sequenceName="SEQ_ENTIDADE", allocationSize = 1, initialValue = 1) public class Entidade implements Serializable, Auditable { private static final long serialVersionUID = 1L; @Id @GeneratedValue(strategy = GenerationType.AUTO,generator="SEQ_ENTIDADE") private Long id; private String nome; @OneToMany(cascade={CascadeType.ALL, CascadeType.REMOVE, CascadeType.REFRESH}) private Set contatos = new HashSet(); // public Long getId() { return id; } public void setId(Long id) { this.id = id; } public Set getContatos() { return contatos; } public void setContatos(Set contatos) { this.contatos = contatos; } public String getNome() { return nome; } public void setNome(String nome) { this.nome = nome; } // // @Override public int hashCode() { int hash = 0; hash += (id != null ? id.hashCode() : 0); hash += (nome != null ? nome.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 Entidade)) { return false; } Entidade other = (Entidade) object; if ((this.id == null && other.id != null) || (this.id != null && !this.id.equals(other.id))) { return false; } return true; } @Override public String toString() { return "audit.teste.model.Entidade[id=" + id + ",nome="+ nome +"]"; } // }