我有一個類,Document
和幾個子類(Invoice
,PurchaseOrder
等)。我添加了一個鑑別到Document
像這樣:流利的NHibernate - 添加鑑別器的問題
public class DocumentMapOverride : IAutoMappingOverride<Document>
{
public void Override(AutoMapping<Document> mapping)
{
mapping.DiscriminateSubClassesOnColumn("DocumentType");
}
}
我的理解是,如果我創建一個Invoice
,它會插入類型名稱到DocumentType
列。但是,當我嘗試插入發票時,出現以下異常。
NHibernate.Exceptions.GenericADOException : could not insert: [MyNamespace.Invoice#101][SQL: INSERT INTO "Document" (Version, DocumentNumber, DocumentDate, DbDate, Sender_id, Receiver_id, SenderAlias_id, ReceiverAlias_id, Process_id, Id) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)]
----> System.Data.SQLite.SQLiteException : Abort due to constraint violation
Document.DocumentType may not be NULL
有什麼建議嗎?
- FluentNHibernate 1.0
- SQLite的
- C#/ .Net4.0
http://pastie.org/1175300此NUnit測試顯示我的錯誤。 – 2010-09-23 12:56:37