/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package negocio;

import com.tecgraf.dao.IEntityDAOJPA;
import java.io.Serializable;
import java.util.Collection;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.Id;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;

/**
 *
 * @author 42071420687
 */
@Entity
@Table(name = "aluno")
@NamedQueries({@NamedQuery(name = "Aluno.findById", query = "SELECT a FROM Aluno a WHERE a.id = :id"), 
@NamedQuery(name = "Aluno.findByNome", query = "SELECT a FROM Aluno a WHERE a.nome = :nome"), 
@NamedQuery(name = "Aluno.findByMatricula", query = "SELECT a FROM Aluno a WHERE a.matricula = :matricula")})

public class Aluno implements IEntityDAOJPA<Integer>, Serializable {
    private static final long serialVersionUID = 1L;
    @Id    @Column(name = "id", nullable = false)
    private Integer id;
    @Column(name = "nome")
    private String nome;
    @Column(name = "matricula")
    private String matricula;
    @OneToMany(mappedBy = "idAluno", fetch=FetchType.EAGER, cascade=CascadeType.ALL)
    private Collection<Disciplina> disciplinaCollection;

    public Aluno() {
    }

    public Aluno(Aluno a) {
      id = a.id;
      nome= new String(a.nome.toCharArray());
      matricula= new String(a.matricula.toCharArray());
      disciplinaCollection = a.disciplinaCollection;      
    }

    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 String getMatricula() {
        return matricula;
    }

    public void setMatricula(String matricula) {
        this.matricula = matricula;
    }

    public Collection<Disciplina> getDisciplinaCollection() {
        return disciplinaCollection;
    }

    public void setDisciplinaCollection(Collection<Disciplina> disciplinaCollection) {
        this.disciplinaCollection = disciplinaCollection;
    }

    @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 Aluno)) {
            return false;
        }
        Aluno other = (Aluno) 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 "negocio.Aluno[id=" + id + " nome=" + nome + " matricula=" + matricula + "]" ;
    }

}
