package DB;

import java.io.Serializable;
import javax.persistence.*;
import java.util.List;


/**
 * The persistent class for the lecture database table.
 * 
 */
@Entity
@Table(name="lecture")
@NamedQuery(name="Lecture.findAll", query="SELECT l FROM Lecture l")
public class Lecture implements Serializable {
	private static final long serialVersionUID = 1L;
	private LecturePK id;
	private Course courseBean;
	private List<StudentAttendance> studentAttendances;

	public Lecture() {
	}


	@EmbeddedId
	public LecturePK getId() {
		return this.id;
	}

	public void setId(LecturePK id) {
		this.id = id;
	}


	//bi-directional many-to-one association to Course
	@ManyToOne
	@JoinColumn(name="course", nullable=false, insertable=false, updatable=false)
	public Course getCourseBean() {
		return this.courseBean;
	}

	public void setCourseBean(Course courseBean) {
		this.courseBean = courseBean;
	}


	//bi-directional many-to-one association to StudentAttendance
	@OneToMany(mappedBy="lecture")
	public List<StudentAttendance> getStudentAttendances() {
		return this.studentAttendances;
	}

	public void setStudentAttendances(List<StudentAttendance> studentAttendances) {
		this.studentAttendances = studentAttendances;
	}

	public StudentAttendance addStudentAttendance(StudentAttendance studentAttendance) {
		getStudentAttendances().add(studentAttendance);
		studentAttendance.setLecture(this);

		return studentAttendance;
	}

	public StudentAttendance removeStudentAttendance(StudentAttendance studentAttendance) {
		getStudentAttendances().remove(studentAttendance);
		studentAttendance.setLecture(null);

		return studentAttendance;
	}

}