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

后端 未结 4 1508
太阳男子
太阳男子 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 05:54

    The student_course table is there purely to record the association between the two entities. It is managed by hibernate, and can contain no other data.

    The sort of data you want to record needs to be modelled as another entity. Perhaps you could a one-to-many association between Course and StudentResult (which contains the grade, etc), and then a many-to-one association between StdentResult and Student.

提交回复
热议问题