FluentNHibernate Component.ColumnPrefix 未应用
我最近将 FluentNHibernate 从 v1.1.0.685 升级到 v1.2.0.712(最新),适用于 NHibernate 2.1 。
我的问题似乎与使用 Component().ColumnPrefix()
映射的类有关。
例如,
public class Address{
public string Street {get; set;}
public string Zip {get; set;}
}
public class AddressMap : ComponentMap<Address>{
Map( x => x.Street );
Map( x => x.Zip );
}
public class PersonMap : ClassMap<Person>
{
public PersonMap(){
Id( x => x.Id );
Map( x=> x.Name );
Component( x => x.Address )
.ColumnPrefix("ADDRESS_");
}
}
人员表
Id Name ADDRESS_Street ADDRESS_Zip
----------------------------------------------------
1 Brian 123 Example St. 12345
FNH v1.1.0.685 中的
行为“ADDRESS_” 前缀正确应用于地址组件的属性。
FNH v1.2.0.712(最新)中的行为
“ADDRESS_” 前缀不再应用于地址组件的属性。 NHiberante 生成上表中未命名的“Street”和“Zip”列。
如果有人有任何见解,我将不胜感激。我开始认为这可能是一个错误。
谢谢,
布莱恩
I recently upgraded FluentNHibernate from v1.1.0.685 to v1.2.0.712 (latest) for NHibernate 2.1.
My issue appears to be with classes that use the Component().ColumnPrefix()
mapping.
For example,
public class Address{
public string Street {get; set;}
public string Zip {get; set;}
}
public class AddressMap : ComponentMap<Address>{
Map( x => x.Street );
Map( x => x.Zip );
}
public class PersonMap : ClassMap<Person>
{
public PersonMap(){
Id( x => x.Id );
Map( x=> x.Name );
Component( x => x.Address )
.ColumnPrefix("ADDRESS_");
}
}
Person Table
Id Name ADDRESS_Street ADDRESS_Zip
----------------------------------------------------
1 Brian 123 Example St. 12345
Behavior in FNH v1.1.0.685
The "ADDRESS_" prefix is correctly applied to the properties of the Address component.
Behavior in FNH v1.2.0.712 (latest)
The "ADDRESS_" prefix is no longer applied to the properties of the Address component. NHiberante generates "Street" and "Zip" columns which are not named in table above.
I'd appreciate if anyone has any insight. I'm beginning to think this might be a bug.
Thanks,
Brian
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
@Brian,
几周前我遇到了确切的障碍。我正在使用自动映射,并通过创建组件属性约定来解决它:
可能有很多方法来实现您的接受标准,所以如果不适合,请不要遵循我的...
干杯
@Brian,
I hit the exact roadblock a few weeks ago. I'm using automappings and got around it by creating a Component Property Convention:
There's probably a wealth of ways to implement your acceptance criteria so don't follow mine if it doesnt suit...
Cheers
在研究了源代码中的单元测试之后;就我而言,我的约定在 FNH v1.1 和 FNH v1.2 之间的应用似乎有所不同。
我认为发生的事情是这样的:
My
将被执行(这里没有问题)。AddressMap : ComponentMap
我的
PersonMap : ClassMap
将使用以下方式映射组件:来自步骤 1。
我的 FNH
MyPropertyConvention
将调用:它出现:
在 FNH v1.1< 调用
instance.Column()
时,步骤 3 对列前缀不会造成破坏。在 FNH v1.2 中,步骤 3 对之前设置的任何
ColumnPrefix()
具有破坏性,并且会覆盖整个 列名称(包括前缀)。因此,我使用
IPropertyConventionAcceptance
清理了 FNH 1.2 的约定,并小心调用instance.Column(instance.Name)
[现在调用对列前缀具有破坏性]。感谢大家的帮助,
布莱恩
After investigating the unit tests in the source code; it appears that, in my case, my conventions were being applied differently between FNH v1.1 and FNH v1.2.
I think this is what happened:
My
AddressMap : ComponentMap<Address>
would get executed (no problem here).My
PersonMap : ClassMap<Person>
would map a component using:from Step 1.
My FNH
MyPropertyConvention
would call:It appears:
in FNH v1.1, Step 3 is not destructive to the column prefix when calling
instance.Column()
.in FNH v1.2, Step 3 is destructive to any
ColumnPrefix()
previously set and over-writes the entire column name (including the prefix).So, I cleaned up my conventions for FNH 1.2 using
IPropertyConventionAcceptance
being careful about my calls toinstance.Column(instance.Name)
[now that calls are destructive to column prefixes].Thanks for everyone's help,
Brian
您需要创建一个
ComponentMap
类才能应用
ColumnPrefix
。请参阅此处: http://wiki. Fluentnhibernate.org/Fluent_mapping#ComponentMap.3CT.3E< /a>
You need to create a
ComponentMap<Address>
class in order for theColumnPrefix
to be applied.See here: http://wiki.fluentnhibernate.org/Fluent_mapping#ComponentMap.3CT.3E