NHibernate Mapping(Attributes):KeyProperty没有持久化

时间:2010-02-03 14:38:21

标签: .net nhibernate attributes mapping

在我目前的项目中,工作流程有评论。请查看以下代码。

[CompositeId]
[KeyProperty(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; }

在底线下方描述了workflows(1)<---->(n)comments的关系(每个日期一个)。 保存此类型的实体时,数据库会报告一个约束违规,表示列“datum”不能为null - 它不是null(该对象具有值)。

我认为定义一个KeyProperty足以让这个字段保持不变,但显然NHibernate看到了另一种方式......

有人在此映射中看到错误吗?

1 个答案:

答案 0 :(得分:0)

我不知道这是否会回到如此不祥的NH Bug,但它现在有效,没有我改变任何东西:(