【问题标题】:What's difference between @JoinColumn and @JoinTable in One-To-Many relationship?@JoinColumn 和 @JoinTable 在一对多关系中有什么区别?
【发布时间】:2014-03-20 22:27:49
【问题描述】:

我遇到了Hibernate问题,@JoinColumn和@JoinTable在一对多关系中有什么区别?

提前致谢。

【问题讨论】:

    标签: database hibernate orm annotations


    【解决方案1】:

    JoinColumn 使用...连接列来映射关联:

    Order        Line
    -----        ----
    id           id
    ...          order_id (FK to order.id)
                 ...
    

    JoinTable 使用...连接表来映射关联:

    Order        Order_Line                           Line
    -----        ----------                           ----
    id           order_id (FK to order.id)            id
    ...          line_id (FK to line.id, unique)      ...   
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-06-03
      • 2010-10-20
      • 1970-01-01
      • 1970-01-01
      • 2011-05-23
      • 2015-12-18
      相关资源
      最近更新 更多