| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051 |
- package nju.seec.SEECdemo.data.entity;
- import lombok.Data;
- import lombok.EqualsAndHashCode;
- import lombok.ToString;
- import nju.seec.SEECdemo.data.entity.assignment.Code;
- import nju.seec.SEECdemo.data.user.User;
- import org.hibernate.annotations.LazyCollection;
- import org.hibernate.annotations.LazyCollectionOption;
- import javax.persistence.*;
- import java.util.HashSet;
- import java.util.Set;
- @Data
- @EqualsAndHashCode(exclude = {"codeSet", "groupSet", "creator"})
- @ToString(exclude = {"codeSet", "groupSet", "creator"})
- @Entity
- @Table(name = "ENTITY_COURSE")
- public class Course {
- @Id
- @GeneratedValue(strategy = GenerationType.IDENTITY)
- @Column(name = "id")
- private Integer id;
- @Basic
- @Column(name = "name", nullable = false)
- private String name;
- @ManyToOne(targetEntity = User.class, fetch = FetchType.LAZY)
- @JoinColumn(name = "creator", referencedColumnName = "id")
- private User creator;
- @OneToMany(targetEntity = Code.class, mappedBy = "course", cascade = CascadeType.REMOVE)
- @LazyCollection(LazyCollectionOption.EXTRA)
- private Set<Code> codeSet = new HashSet<>();
- @ManyToMany(targetEntity = User.class, cascade = CascadeType.DETACH)
- @JoinTable(name = "LINK_USER_COURSE",
- joinColumns = @JoinColumn(name = "course", referencedColumnName = "id"),
- inverseJoinColumns = @JoinColumn(name = "user", referencedColumnName = "id")
- )
- @LazyCollection(LazyCollectionOption.EXTRA)
- private Set<User> memberSet = new HashSet<>();
- @OneToMany(targetEntity = Group.class, mappedBy = "course", cascade = CascadeType.REMOVE)
- @LazyCollection(LazyCollectionOption.EXTRA)
- private Set<Group> groupSet = new HashSet<>();
- }
|