/* * To change this template, choose Tools | Templates * and open the template in the editor. */ package empresa.negocio; import com.tecgraf.dao.IEntityDAOJPA; import java.io.Serializable; import java.util.Date; import javax.persistence.Column; import javax.persistence.Entity; import javax.persistence.Id; import javax.persistence.JoinColumn; import javax.persistence.ManyToOne; import javax.persistence.NamedQueries; import javax.persistence.NamedQuery; import javax.persistence.Table; import javax.persistence.Temporal; import javax.persistence.TemporalType; /** * * @author s092 */ @Entity @Table(name = "dependente") @NamedQueries({@NamedQuery(name = "Dependente.findById", query = "SELECT d FROM Dependente d WHERE d.id = :id"), @NamedQuery(name = "Dependente.findByNome", query = "SELECT d FROM Dependente d WHERE d.nome = :nome"), @NamedQuery(name = "Dependente.findByDatanascimento", query = "SELECT d FROM Dependente d WHERE d.datanascimento = :datanascimento")}) public class Dependente implements IEntityDAOJPA, Serializable { private static final long serialVersionUID = 1L; @Id @Column(name = "id", nullable = false) private Integer id; @Column(name = "nome", nullable = false) private String nome; @Column(name = "datanascimento") @Temporal(TemporalType.TIMESTAMP) private Date datanascimento; @JoinColumn(name = "idempregado", referencedColumnName = "id") @ManyToOne private Empregado idempregado; public Dependente() { } public Dependente( Integer id ) { this.id = id; } public Dependente( Integer id, String nome ) { this.id = id; this.nome = nome; } public Integer getId() { return id; } public void setId( Integer id ) { this.id = id; } public String getNome() { return nome; } public void setNome( String nome ) { this.nome = nome; } public Date getDatanascimento() { return datanascimento; } public void setDatanascimento( Date datanascimento ) { this.datanascimento = datanascimento; } public Empregado getIdempregado() { return idempregado; } public void setIdempregado( Empregado idempregado ) { this.idempregado = idempregado; } @Override public int hashCode() { int hash = 0; hash += (id != null ? id.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 Dependente) ) { return false; } Dependente other = (Dependente)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 "empresa.negocio.Dependente["+ id + " " + nome.trim() + "]: " + " data nascimento: " + getDatanascimento() + " " + " - empregado: " + idempregado.getNome().trim(); } }