Reputation:
I have a mapping as follows:
public class InvoiceDetailMapping : ClassMap<InvoiceDetail>
{
public InvoiceDetailMapping()
{
Id(x => x.DetailId)
.GeneratedBy.Guid();
Map(x => x.Account);
Map(x => x.Credit);
Map(x => x.Debit);
Map(x => x.PayType);
Map(x => x.RowNumber);
References<InvoiceItem>(x => x.Invoice, "InvoiceItemId")
.Cascade.All();
}
}
public class InvoiceItemMapping : ClassMap<InvoiceItem>
{
public InvoiceItemMapping()
{
Id(x => x.RecordId)
.GeneratedBy.Guid();
Map(x => x.BatchId);
Map(x => x.Description);
Map(x => x.DocumentDate);
Map(x => x.DocumentId);
Map(x => x.DocumentType);
Map(x => x.FileId);
Map(x => x.FileName);
Map(x => x.InvoiceAmount);
Map(x => x.LocationCode);
Map(x => x.PayDate);
Map(x => x.PaymentTerms);
Map(x => x.PayNumber);
Map(x => x.PurchaseAmount);
Map(x => x.PurchaseInvoiceAmount);
Map(x => x.InvoiceId);
Map(x => x.Submittable);
Map(x => x.SubmittedBy);
Map(x => x.SubmittedTimeStamp);
Map(x => x.TaxForm1099Amount);
Map(x => x.TroubleClass);
Map(x => x.VendorDocNumber);
Map(x => x.VendorId);
Map(x => x.PersistedTimeStamp)
.CustomType<UtcDateTimeType>()
.Generated.Insert();
HasMany<InvoiceDetail>(x => x.InvoiceDetails)
.Inverse()
.Cascade.All()
.KeyColumn("InvoiceItemId");
}
}
... but when I apply this to my PostgreSQL database, it creates the following SQL for the InvoiceDetail:
CREATE TABLE "InvoiceDetail"
(
detailid uuid NOT NULL,
account character varying(255),
credit numeric(19,5),
debit numeric(19,5),
paytype integer,
rownumber integer,
invoiceitemid uuid,
CONSTRAINT "InvoiceDetail_pkey" PRIMARY KEY (detailid ),
CONSTRAINT fkd8588014e9009e93 FOREIGN KEY (invoiceitemid)
REFERENCES "InvoiceItem" (recordid) MATCH SIMPLE
ON UPDATE NO ACTION ON DELETE NO ACTION
Note the ON UPDATE NO ACTION ON DELETE NO ACTION
line. I would have thought the Cascade.All()
directive would create a ON UPDATE CASCADE ON DELETE CASCADE
DDL. What did I do incorrectly or incompletely?
Upvotes: 2
Views: 877
Reputation: 30813
NH supports many different RDBMS and already for a long time hence the default is to do it in code. FNH on the other hand startet to implement the most common features which this one is not. And there was still no one filing an issue to support this NH feature. Also it is difficult to say because in the mapping the Dialect is not known hence it can not know if the feature is even supported.
Upvotes: 1