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

package entities;

import java.io.Serializable;
import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Table;

/**
 *
 * @author Szilárd
 */
@Entity
@Table(name = "current_subject")
@NamedQueries({
    @NamedQuery(name = "CurrentSubject.findAll", query = "SELECT c FROM CurrentSubject c"),
    @NamedQuery(name = "CurrentSubject.findByOpen", query = "SELECT c.subjectId FROM CurrentSubject c WHERE c.semesterId = :semesterId"),
    @NamedQuery(name = "CurrentSubject.findBySemesterAndSubject", query = "SELECT c FROM CurrentSubject c WHERE c.semesterId = :semesterId AND c.subjectId = :subjectId")
})
    
public class CurrentSubject implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Basic(optional = false)
    @Column(name = "Id")
    private Long id;

    @JoinColumn(name = "Semester_Id", referencedColumnName = "ID")
    @ManyToOne
    private Semester semesterId;
    
    @JoinColumn(name = "Subject_Id", referencedColumnName = "ID")
    @ManyToOne
    private Subject subjectId;


    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    public Semester getSemesterId() {
        return semesterId;
    }

    public void setSemesterId(Semester semesterId) {
        this.semesterId = semesterId;
    }

    public Subject getSubjectId() {
        return subjectId;
    }

    public void setSubjectId(Subject subjectId) {
        this.subjectId = subjectId;
    }

    

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

}
