我有 2 个这样映射的 POCO:
<?xml version="1.0" encoding="utf-8" ?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2">
<class name="APPayment" table="APPayments">
<id name="PaymentId">
<generator class="guid" />
</id>
<many-to-one name="Invoice" class="APInvoice" cascade="none"
column="InvoiceId" index="ixPaymentInvoice" not-null="true" />
</class>
<class name="APInvoice" table="APInvoices">
<id name="InvoiceId">
<generator class="guid" />
</id>
<bag name="Payments" inverse="true" cascade="none" >
<key column="PaymentId" foreign-key="fkInvoicePayments" />
<one-to-many class="APPayment" />
</bag>
</class>
</hibernate-mapping>
出于某种我无法理解的原因,我在我的APPayments
表上生成了重复的外键:
fk9cdfbf509640182e
fkinvoicepayments
我认为这也导致了保存对象关系的一些其他问题。我是否错误配置了映射?我需要做什么才能使其正常工作?