Hibernate 复合注释
我是 Hibernate 的新手,正在尝试将连接表中的额外列映射到父类。我可以在 http://docs.jboss 找到一个示例.org/hibernate/core/3.5/reference/en/html/components.html
<class name="eg.Order" .... >
....
<set name="purchasedItems" table="purchase_items" lazy="true">
<key column="order_id">
<composite-element class="eg.Purchase">
<property name="purchaseDate"/>
<property name="price"/>
<property name="quantity"/>
<many-to-one name="item" class="eg.Item"/> <!-- class attribute is optional -->
</composite-element>
</set>
</class>
我想要纯注释中的上述 xml 示例。任何帮助将不胜感激。
谢谢
I am new to Hibernate, and am trying to map extra columns in a join table to the parent class. I could find an example at http://docs.jboss.org/hibernate/core/3.5/reference/en/html/components.html
<class name="eg.Order" .... >
....
<set name="purchasedItems" table="purchase_items" lazy="true">
<key column="order_id">
<composite-element class="eg.Purchase">
<property name="purchaseDate"/>
<property name="price"/>
<property name="quantity"/>
<many-to-one name="item" class="eg.Item"/> <!-- class attribute is optional -->
</composite-element>
</set>
</class>
I want the above xml example in pure annotation. Any help will be greatly appreciated.
Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
采购类别:
订购类别:
Purchase class:
Order class:
请参阅http://docs.jboss.org /hibernate/core/3.6/reference/en-US/html_single/#collections-ofvalues。从 3.6、IIRC 开始,注释就成为 hibernate 核心的一部分,因此注释的文档被嵌入到 3.6 的核心文档中。对于以前的版本,它是单独记录的(请参阅 http:// docs.jboss.org/hibernate/stable/annotations/reference/en/html_single/#d0e1821)
See http://docs.jboss.org/hibernate/core/3.6/reference/en-US/html_single/#collections-ofvalues. annotations are part of the hibernate core since 3.6, IIRC, and the documentation for annotations is thus embedded in the core documentation of 3.6. For previous versions, it was documented separately (see http://docs.jboss.org/hibernate/stable/annotations/reference/en/html_single/#d0e1821)