/* * 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.math.BigDecimal; import java.util.Collection; import javax.persistence.Column; import javax.persistence.Entity; import javax.persistence.Id; import javax.persistence.NamedQueries; import javax.persistence.NamedQuery; import javax.persistence.OneToMany; import javax.persistence.Table; /** * * @author s092 */ @Entity @Table(name = "departamento") @NamedQueries({@NamedQuery(name = "Departamento.findById", query = "SELECT d FROM Departamento d WHERE d.id = :id"), @NamedQuery(name = "Departamento.findByNumero", query = "SELECT d FROM Departamento d WHERE d.numero = :numero"), @NamedQuery(name = "Departamento.findByNome", query = "SELECT d FROM Departamento d WHERE d.nome = :nome"), @NamedQuery(name = "Departamento.findByOrcamento", query = "SELECT d FROM Departamento d WHERE d.orcamento = :orcamento"), @NamedQuery(name = "Departamento.findByLocacao", query = "SELECT d FROM Departamento d WHERE d.locacao = :locacao")}) public class Departamento implements IEntityDAOJPA, Serializable { private static final long serialVersionUID = 1L; @Id @Column(name = "id", nullable = false) private Integer id; @Column(name = "numero", nullable = false) private int numero; @Column(name = "nome") private String nome; @Column(name = "orcamento") private BigDecimal orcamento; @Column(name = "locacao") private String locacao; @OneToMany(mappedBy = "iddepartamento") private Collection empregadoCollection; public Departamento() { } public Departamento( Integer id ) { this.id = id; } public Departamento( Integer id, int numero ) { this.id = id; this.numero = numero; } public Integer getId() { return id; } public void setId( Integer id ) { this.id = id; } public int getNumero() { return numero; } public void setNumero( int numero ) { this.numero = numero; } public String getNome() { return nome; } public void setNome( String nome ) { this.nome = nome; } public BigDecimal getOrcamento() { return orcamento; } public void setOrcamento( BigDecimal orcamento ) { this.orcamento = orcamento; } public String getLocacao() { return locacao; } public void setLocacao( String locacao ) { this.locacao = locacao; } public Collection getEmpregadoCollection() { return empregadoCollection; } public void setEmpregadoCollection( Collection empregadoCollection ) { this.empregadoCollection = empregadoCollection; } @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 Departamento) ) { return false; } Departamento other = (Departamento)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.Departamento[" + id + " " + nome.trim() + "]: " + " endereco: " + locacao.trim() + " " + numero + " - orcamento: " + orcamento; } }