Attributes on Many-to-Many relationships (Hibernate)

前端 未结 2 1835
失恋的感觉
失恋的感觉 2021-01-02 13:06

I have entity classes A and C. They are mapping the tables tblA and tblC and have a many-to-many relationship between them, with tblB to map between them. tblB contains A_ID

相关标签:
2条回答
  • 2021-01-02 13:50

    See

    @ManyToMany Hibernate Question (can add extra field?)

    And

    how to make a composite primary key (java persistence annotation)

    regards,

    0 讨论(0)
  • 2021-01-02 13:55

    From what I know, it is not possible to map it this way, you have to switch to One-To-Many and a Many-To-One relationships, with your B in the middle. Your date will be an attribute of B.


    For this lack of evolutivity, the Hibernate documentation recommends to avoid the Many-To-Many in general, and use the two relationships from the beginning.

    0 讨论(0)
提交回复
热议问题