【问题标题】:Accessing column from Collection of Collection using Hibernate mapping使用 Hibernate 映射从 Collection 访问列
【发布时间】:2009-02-10 16:00:47
【问题描述】:

请求.hbm.xml:

    <id name="reqId" type="long" column="REQ_ID"> 
        <generator class="sequence">
            <param name="sequence">SEQUENCE</param> 
        </generator>
    </id>


    <bag name="lines" lazy="false" >
        <key column="REQ_ID" not-null="true" />
        <one-to-many class="com.Lines" />
    </bag>

Lines.hbm.xml

    <id name="lineId" type="string" column="LINE">
        <generator class="assigned" />
    </id>

    <property name="reqId" type="long" column="REQ_ID" />

    <bag name="comments">
        <key column="LINE" />
        <one-to-many class="com.Comments"/>
    </bag>

评论.hbm.xml:

Req.java 将包含行列表。和 Line.java 有 cmets 列表。

在使用投影检索列时...如何从 CMNTS 表中检索列。

lines.cmets.commentId 可以在 Projection 中使用,我可以检索列吗?

如何在 CMNTS 表的条件类中定义连接?

【问题讨论】:

    标签: hibernate collections


    【解决方案1】:

    不,你不能只去“lines.cmets.commentId”,你需要使用投影别名来遍历多个集合。看看 Projections.alias()

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2011-02-17
      • 1970-01-01
      • 1970-01-01
      • 2010-10-05
      • 2011-07-31
      • 2021-10-24
      • 1970-01-01
      相关资源
      最近更新 更多