Note that there are some explanatory texts on larger screens.

plurals
  1. POCan add extra field(s) to @ManyToMany Hibernate extra table?
    primarykey
    data
    text
    <p>I have these two class(table)</p> <pre><code>@Entity @Table(name = "course") public class Course { @Id @Column(name = "courseid") private String courseId; @Column(name = "coursename") private String courseName; @Column(name = "vahed") private int vahed; @Column(name = "coursedep") private int dep; @ManyToMany(fetch = FetchType.LAZY) @JoinTable(name = "student_course", joinColumns = @JoinColumn(name = "course_id"), inverseJoinColumns = @JoinColumn(name = "student_id")) private Set&lt;Student&gt; student = new HashSet&lt;Student&gt;(); //Some setter and getter </code></pre> <p>and this one:</p> <pre><code> @Entity @Table(name = "student") public class Student { @Id @Column(name="studid") private String stId; @Column(nullable = false, name="studname") private String studName; @Column(name="stmajor") private String stMajor; @Column(name="stlevel", length=3) private String stLevel; @Column(name="stdep") private int stdep; @ManyToMany(fetch = FetchType.LAZY) @JoinTable(name = "student_course" ,joinColumns = @JoinColumn(name = "student_id") ,inverseJoinColumns = @JoinColumn(name = "course_id") ) private Set&lt;Course&gt; course = new HashSet&lt;Course&gt;(); //Some setter and getter </code></pre> <p>After running this code an extra table was created in database(student_course), now I wanna know how can I add extra field in this table like (Grade, Date , and ... (I mean student_course table)) I see some solution but I don't like them, Also I have some problem with them:</p> <p><a href="http://boris.kirzner.info/blog/archives/2008/07/19/hibernate-annotations-the-many-to-many-association-with-composite-key/" rel="noreferrer">First Sample</a></p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload