开发者

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 :(

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜