为什么流利NHibernate忽略我对组件的唯一约束? [英] Why is Fluent NHibernate ignoring my unique constraint on a component?
问题描述
在我的地图中,我有:
$ p $ 组件(
x => x.ExposureKey,
m => {
m.Map(x => x.AsOfDate).Not.Nullable();
m.Map(x => x.ExposureId).Length(30) .Nullable();
}
).Unique();
HBM的相关输出是
< component name =ExposureKeyinsert =trueupdate =trueoptimistic-lock =trueclass =Some.Namespace.CreditExposureKey,Some.Namespace,Version = 0.0.0.0,Culture = neutral,PublicKeyToken = aaaaaaaaaaaaaaaa>
< property name =AsOfDatetype =System.DateTime,mscorlib,Version = 4.0.0.0,Culture = neutral,PublicKeyToken = b77a5c561934e089>
< column name =AsOfDatenot-null =true/>
< / property>
< property name =ExposureIdtype =System.String,mscorlib,Version = 4.0.0.0,Culture = neutral,PublicKeyToken = b77a5c561934e089>
< column name =ExposureIdlength =30not-null =true/>
< / property>
< / component>
显然缺少 unique =true
从组件
定义。
为什么会发生这种情况?
流利NHibernate的版本?根据 检查生成的SQL是否具有 In my map I have: The relevant output from the HBM is which is clearly missing Why is this happening? Are you using the latest version of Fluent NHibernate? According to James Gregory (Fluent NHibernate contributor), it should work. It would also be good to check if the generated SQL actually has the 这篇关于为什么流利NHibernate忽略我对组件的唯一约束?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋! <$ c (x => x.ExposureKey,m =>
{
m.Map(x => x.AsOfDate) .Not.Nullable();
m.Map(x => x.ExposureId).Length(30).Not.Nullable();
})。SetAttribute(unique,true );
Unique
属性集,即使hbm映射文件没有(可能是一个小错误)。Component(
x => x.ExposureKey,
m => {
m.Map(x => x.AsOfDate).Not.Nullable();
m.Map(x => x.ExposureId).Length(30).Not.Nullable();
}
).Unique();
<component name="ExposureKey" insert="true" update="true" optimistic-lock="true" class="Some.Namespace.CreditExposureKey, Some.Namespace, Version=0.0.0.0, Culture=neutral, PublicKeyToken=aaaaaaaaaaaaaaaa">
<property name="AsOfDate" type="System.DateTime, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<column name="AsOfDate" not-null="true"/>
</property>
<property name="ExposureId" type="System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<column name="ExposureId" length="30" not-null="true"/>
</property>
</component>
unique="true"
from the component
definition. // Else, try this hack:
Component(x => x.ExposureKey, m =>
{
m.Map(x => x.AsOfDate).Not.Nullable();
m.Map(x => x.ExposureId).Length(30).Not.Nullable();
}).SetAttribute("unique", "true");
Unique
property set even if the hbm mapping files do not (could be a small bug).