在 Fluent NHibernate 中查找重复映射的来源
今天早些时候,我将一个类一分为二,将原始类标记为抽象类,并创建两个从抽象基类继承的子类。
我在 FluentNHibernate 映射中添加了一行,以根据列值(每类表层次结构)区分子类,如下所示:
DiscriminateSubClassesOnColumn("EntryType");
该字段是数据库中的整数。
我的新映射继承自
SubClassMap<MyChildType>
With a new line in the constructor method of MyChildTypeMap for the discriminator 如下:
DiscriminatorValue(1);
我不断遇到此异常:
"Duplicate class/entity mapping MyNamespace.MyChildObject"
在 Fluent NHibernate 会话构建器中,(Fluently.Configure()....) 我添加了行将映射导出到 hbm 文件。果然,子类在父类的映射文件中被列出了两次。
我没有使用 AutoMapped 配置。 我正在使用 Fluent NHibernate 1.2.0.0 我正在使用 NHibernate 3.2.0.400
我束手无策,试图找出它的来源。有人可以帮忙吗?
Earlier today, I broke one of my classes into two, by marking the original as abstract, and creating two subclasses that inherit from the abstract base.
I added a line to my FluentNHibernate mapping to discriminate the subclasses based on a column value (table-per-class heirarchy) as follows:
DiscriminateSubClassesOnColumn("EntryType");
That field is an integer in the database.
My new mappings inherit from
SubClassMap<MyChildType>
With a new line in the constructor method of MyChildTypeMap for the discriminator as follows:
DiscriminatorValue(1);
I am continuously running into this exception:
"Duplicate class/entity mapping MyNamespace.MyChildObject"
In the Fluent NHibernate session builder, (Fluently.Configure()....) I added the line to export the mappings to hbm files. Sure enough, the subclass is listed twice in the mapping file of the parent class.
I am not using AutoMapped configurations.
I am using Fluent NHibernate 1.2.0.0
I am using NHibernate 3.2.0.400
I'm at wit's end trying to figure out where this comes from. Can anyone help?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
查看映射是如何构建的一种快速方法是使用 FluentNHibernate 的诊断:
这将传输(在本例中到您的控制台,您也可以
OutputToFile
)调试日志,其中显示正在创建哪些映射课程以及导致添加或跳过课程的原因。A quick way to see how your mappings are constructed is to use FluentNHibernate's diagnostics:
This will stream (to your console in this case, you can also
OutputToFile
) a debug log of what mappings are being created from what classes and what caused them to be added or skipped.