Can add extra field(s) to @ManyToMany Hibernate extra table?

后端 未结 4 1507
太阳男子
太阳男子 2020-11-28 05:16

I have these two class(table)

@Entity
@Table(name = \"course\")
public class Course {

    @Id
    @Column(name = \"courseid\")
    private String courseId;
         


        
4条回答
  •  攒了一身酷
    2020-11-28 06:07

    Drop the many-to-many, create a class called StudentCourseRelationship and set up one to manys on Student and Course to the StudentCourseRelationship.

    You can put all sorts of things on it, like DateEnrolled, DateKickedOut etc. etc.

    IMO the many-to-many mapping is a bit of a con.

提交回复
热议问题