在 Fluent NHibernate 中查找重复映射的来源

发布于 2024-12-08 14:46:49 字数 749 浏览 0 评论 0原文

今天早些时候,我将一个类一分为二,将原始类标记为抽象类,并创建两个从抽象基类继承的子类。

我在 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

澉约 2024-12-15 14:46:49

查看映射是如何构建的一种快速方法是使用 FluentNHibernate 的诊断:

Fluently.Configure()
    .Database(\\your db stuff here)
    .Diagnostics(diag => diag.Enable().OutputToConsole())
    .Mappings(\\mappings);

这将传输(在本例中到您的控制台,您也可以 OutputToFile)调试日志,其中显示正在创建哪些映射课程以及导致添加或跳过课程的原因。

A quick way to see how your mappings are constructed is to use FluentNHibernate's diagnostics:

Fluently.Configure()
    .Database(\\your db stuff here)
    .Diagnostics(diag => diag.Enable().OutputToConsole())
    .Mappings(\\mappings);

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文