46 lines
1.0 KiB
Java
46 lines
1.0 KiB
Java
package ovh.herisson.Clyde.Tables;
|
|
|
|
import jakarta.persistence.*;
|
|
import lombok.AllArgsConstructor;
|
|
import lombok.Data;
|
|
import lombok.NoArgsConstructor;
|
|
import ovh.herisson.Clyde.Tables.Msg.Forum;
|
|
|
|
import java.util.List;
|
|
|
|
import org.hibernate.annotations.OnDelete;
|
|
import org.hibernate.annotations.OnDeleteAction;
|
|
|
|
@Entity
|
|
@Data
|
|
@NoArgsConstructor
|
|
@AllArgsConstructor
|
|
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;
|
|
|
|
//// Extension Messagerie /////
|
|
@OneToMany(mappedBy = "course", cascade = CascadeType.ALL)
|
|
private List<Forum> forums;
|
|
|
|
public void addForum(Forum f){
|
|
f.setCourse(this);
|
|
forums.add(f);
|
|
}
|
|
///////////////////////////////
|
|
|
|
public Course(int credits, String title, User owner){
|
|
this.credits = credits;
|
|
this.title = title;
|
|
this.owner = owner;
|
|
}
|
|
}
|