映射 NHibernate 的反面协会
Ayende 有一个使用
映射 此处,由于该博文的评论已关闭,我将其作为我的问题的一部分重新发布。鉴于他的原始映射:
<class name="Order" table="Orders">
<id name="Id">
<generator class="native"/>
</id>
<any name="Payment" id-type="System.Int64" meta-type="System.String" cascade="all">
<meta-value value="CreditCard" class="CreditCardPayment"/>
<meta-value value="Wire" class="WirePayment"/>
<column name="PaymentType"/>
<column name="PaymentId"/>
</any>
</class>
<class name="CreditCardPayment" table="CreditCardPayments">
<id name="Id">
<generator class="native"/>
</id>
<property name="IsSuccessful"/>
<property name="Amount"/>
<property name="CardNumber"/>
</class>
<class name="WirePayment" table="WirePayments">
<id name="Id">
<generator class="native"/>
</id>
<property name="IsSuccessful"/>
<property name="Amount"/>
<property name="BankAccountNumber"/>
</class>
...我将如何在 CreditCardPayment 和 WirePayment 类上映射名为 Order 的属性,这将是关联的“另一面”,允许从这些付款遍历回它们关联的 Order?
对我来说,这里的问题是 CreditCardPayment 和 WirePayment 可能具有相同的 ID,因为它们位于不同的表中,因此我需要某种方法来告诉 NHibernate 将 PaymentType 考虑在内。
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
NHibernate 不支持双向异构关联(即
)。我知道这不是你想听的,但仅此而已。
Bidirectional heterogeneous associations (i.e.
<any>
) are not supported by NHibernate.I know this isn't what you wanted to hear, but that's it.