package ovh.herisson.Clyde.Tables;

import jakarta.persistence.*;
import org.hibernate.annotations.OnDelete;
import org.hibernate.annotations.OnDeleteAction;

@Entity
public class Course {
    @Id
    @GeneratedValue(strategy = GenerationType.AUTO)
    private int courseID;
    private int credits;
    private String title;

    @ManyToOne(fetch = FetchType.EAGER)
    @OnDelete(action = OnDeleteAction.SET_NULL)
    @JoinColumn(name = "Users")
    private User owner;

    public Course(int credits, String title, User owner){
        this.credits = credits;
        this.title = title;
        this.owner = owner;
    }

    public Course() {}

    public int getCourseID() {
        return courseID;
    }

    public int getCredits() {
        return credits;
    }

    public void setCredits(int credits){
        this.credits = credits;
    }

    public String getTitle() {
        return title;
    }

    public void setTitle(String title){
        this.title = title;
    }

    public User getOwner() {
        return owner;
    }

    public void setOwner(User owner) {
        this.owner = owner;
    }
}
