【发布时间】:2011-04-29 04:01:29
【问题描述】:
我正在尝试将 .hbm 映射切换为流式映射,但在复合 ID 的映射和接口的使用方面存在问题
类如下所示:
public class ClassWithCompositeId {
public virtual IKeyOne KeyOne { get; set; }
public virtual IKeyTwo KeyTwo { get; set; }
}
我们的 hbm 映射如下所示:
<hibernate-mapping ...>
<class name="ClassWithCompositeId" table="t_classwithcompositeid">
<composite-id>
<key-many-to-one name="KeyOne" column="colkeyone" class="company.namespace.boSkillBase, BL_Stammdaten" />
<key-many-to-one name="KeyTwo" column="colkeytwo" class="boQualifikation" />
</composite-id>
</hibernate-mapping>
请注意,我们在类中有接口!不,我正在尝试使用 Fluent nhibernate 映射它。
Map {
public ClassWithCompositeIdMap() {
CompositeId()
.KeyReference(x => x.KeyOne, "colkeyone")
.KeyReference(x => x.KeyTwo, "colkeytwo");
...
}
}
但现在 Fluent 生成 Mapping 如下:
...
<composite-id mapped="false" unsaved-value="undefined">
<key-many-to-one name="KeyOne" class="company.namespace.IKeyOne, Interfaces, Version=0.1.4.3379, Culture=neutral, PublicKeyToken=null">
<column name="colkeyone" />
</key-many-to-one>
<key-many-to-one name="KeyTwo" class="company.namespace.IKeyTwo, Interfaces, Version=0.1.4.3379, Culture=neutral, PublicKeyToken=null">
<column name="colkeytwo" />
</key-many-to-one>
</composite-id>
...
“类”属性现在指向接口而不是该接口的实现,这会导致错误。
如何告诉 Fluent nHibernate 使用另一个类作为属性值?
【问题讨论】:
-
对不起,boQualifikation 和 boSkill 类应该是 IKeyOne 和 IKeyTwo 的实现
标签: nhibernate interface fluent-nhibernate fluent