JPA ManyToMany, как JoinTable может иметь свойство?

У меня вопрос по проектированию ManyToMany в EJB, как может jointable иметь свойство?
. Вот пример, студенты и курсы являются ManyToMany, каждый студент имеет много курсов, и многие студенты выбирают один курс.

    @Entity
    public class Student implements Serializable { 
        @Id
        @GeneratedValue(strategy = GenerationType.AUTO)
        Long id;
        String name;
        private Collection<Course> courses; 

        @ManyToMany(mappedBy = "students",cascade=CascadeType.ALL)      
        public Collection<Course> getCourses() {
            return this.courses;
        }

        public void setCourses(Collection<Course> courses) {
            this.courses = courses;
        }

    }


    @Entity
    public class Course implements Serializable { 
        @Id
        @GeneratedValue(strategy = GenerationType.AUTO)
        Long id;
        String name; 
        private Collection<Student> students; 

        @ManyToMany(cascade=CascadeType.ALL)
        @JoinTable(name = "Student_Course",
        joinColumns = {@JoinColumn(name = "Course_ID", referencedColumnName = "id")}, 
        inverseJoinColumns = {@JoinColumn(name = "Student_ID", referencedColumnName = "id")})  

        public Collection<Student> getStudents() {
            return this.students;
        }

        public void setStudents(Collection<Student> students) {
            this.students = students;
        }
    }

Однако если у меня есть свойство в JoinTable, например, каждый студент имеет один балл за один курс. Как я могу сделать это в EJB с ManyToMany?
. Большое спасибо за внимание!

10
задан seaguest 21 December 2011 в 10:58
поделиться