NHibernate Mapping (Attributes) : KeyProperty not persisted
In my current project, Workflows have comments. Please have a look at the following code.
[CompositeId]
[KeyProperty开发者_Go百科(1, Column = "datum", Name = "Date", TypeType = typeof(DateTime))]
[KeyManyToOne(1, Column = "workflow_id", Name = "Workflow", ClassType = typeof(Workflow))]
public virtual IWorkflow Workflow { get; set; }
[Property(Column = "kommentar")]
public virtual string CommentText { get; set; }
public virtual DateTime Date { get; set; }
Down the bottom line this describes the relationship workflows(1)<---->(n)comments
(one per date).
When saving an entity of this type, the Database reports a constraint violation saying that column "datum" can't be null - which it ain't (the object has a value for it).
I thought defining a KeyProperty was sufficient for getting this field persisted, but obviously NHibernate sees it another way...
Does anybody see a mistake in this mapping?
I don't know whether this goes back to so ominous NH Bug, but it works now, without me having changed anything :(
精彩评论