【问题标题】:How to retrieve value of Releation Table's column如何检索关系表列的值
【发布时间】:2011-07-31 16:13:46
【问题描述】:

我是休眠新手。目前我陷入了一个问题。
我不知道如何检索关系表列的值。

senario:
i have three tables.
TableA:
-------
a_id
a_col1

TableB:
-------
b_id
b_col1

TableC
-------
c_id
a_id
b_id
c_col1

我已经为 TableA 和 TableB 创建了模型类。我已经使用@ManyToMany 和@JoinTable 注释映射它们

TableA
{
    ...
    private Set<TableB> tableB;
    @ManyToMany
    @JoinTable( name="TableC", 
                joinColumns={@JoinColumn(name="a_id")},
                inverseJoinColumns={@JoinColumn(name="b_id)}
    public getTableB()
    {
        return tableB;
    }
    public setTableB(...) { ... }
}

现在我的问题是:
====================
如何从 TableA 实体中检索 c_col1 的值

【问题讨论】:

    标签: java hibernate jakarta-ee hibernate-mapping


    【解决方案1】:

    你不能。您所看到的是,您实际上并没有 A 和 B 之间的多对多关系。您有三个对象:A、B 和 C,从 C 到 A 和从C 到 B。然后您的 c_col1 列将存在于 C 上。

    【讨论】:

      猜你喜欢
      • 2020-06-14
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-03-06
      • 1970-01-01
      • 2016-09-30
      • 2014-08-13
      相关资源
      最近更新 更多