JPA many to many with extra column

前端 未结 3 1462
小蘑菇
小蘑菇 2020-12-20 12:45

I have a following problem that I need to solve. The core issues is that I want to add additional column into JoinTable for ManyToMany relation in JPA. In my case I have fol

3条回答
  •  無奈伤痛
    2020-12-20 13:08

    I would try to avoid using a List unless you allow duplicates.

    There is a @OrderColumn annotation that automatically does this. Have you tried it?

    @Entity
    public class Topic {
     @Id
     private Long id;
     @Basic
     private String name;
    
     @OneToMany
     @OrderColumn
     private Set association;
    }
    

提交回复
热议问题