jpa 多对多 @JoinTable 联合主键

如下所建多对多关系表的方式,有办法设置联合主键么?现在仅找到了用下面的方法设置联合唯一的方式:

    @ManyToMany(fetch = FetchType.LAZY, cascade = CascadeType.MERGE)
    @JoinTable(name = "course_teacher", 
        joinColumns = @JoinColumn(name = "course_id", nullable=false, updatable=false, foreignKey = @ForeignKey(name = "none", value = ConstraintMode.NO_CONSTRAINT)),
        inverseJoinColumns = @JoinColumn(name = "teacher_id", nullable=false, updatable=false, foreignKey = @ForeignKey(name = "none", value = ConstraintMode.NO_CONSTRAINT)),
         uniqueConstraints = {@UniqueConstraint(columnNames={"course_id", "teacher_id"})}
            )
    private List<Teacher> teachers;
阅读 3.4k
评论 更新于 2017-11-21
    撰写回答

    登录后参与交流、获取后续更新提醒