更新了 Npgsql(1.0 -> 2.05) 并在 NHIbernate 上出现错误 (ObjectNotFoundException)

发布于 2024-07-22 06:49:59 字数 435 浏览 2 评论 0原文

我将 Npgsql 驱动程序更新到最新版本 (2.0.5),但我的 NHibernate 应用程序出现错误... 映射:

学校映射:

......

References(x => x.City);

城市映射:

Id(x => x.ID).GeneratedBy.Assigned();
Map(x => x.Name);
References(x => x.Microrregion);

现在,当我尝试加载学校时,我得到了一个 NHibernate.ObjectNotFoundException 来对象城市...... 但使用 Npgsql 1.0 一切正常......

有什么想法吗?

谢谢

I updated the Npgsql driver to the last version (2.0.5) and got error in my NHibernate App...
Mappings:

School mapping :

...

References(x => x.City);

...

And City Mapping:

Id(x => x.ID).GeneratedBy.Assigned();
Map(x => x.Name);
References(x => x.Microrregion);

Now, when I tried to load a School, I got a NHibernate.ObjectNotFoundException to object City...
But with Npgsql 1.0 all works fine...

Any Idea?

Thanks

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

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

发布评论

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

评论(2

过去的过去 2024-07-29 06:49:59

首先,您确信城市存在吗? 您可以对这两个表运行 SQL 查询吗? 也就是说,SELECT * FROM School LEFT JOIN City ON School.City = City.Id WHERE School.Id = 12345 返回您期望的结果吗?

如果是这样,接下来确保 NHibernate 正在生成您期望的查询。 您可以在 Fluent 界面上设置 show SQL 属性,如下所示:

PostgreSQLConfiguration
    .Standard // Or whatever dialect you are using
    .ConnectionString(...).ShowSql()

设置完成后,NHibernate 将编写它正在执行的查询,并且它可能会显示在您的日志记录或单元测试或其他内容中,具体取决于您的设置方式。

First, are you positive that the City exists? Can you run a SQL query against these two tables? That is, does SELECT * FROM School LEFT JOIN City ON School.City = City.Id WHERE School.Id = 12345 return what you expect?

If so, next make sure NHibernate is generating the query you expect. You can set the show SQL property on the Fluent interface like so:

PostgreSQLConfiguration
    .Standard // Or whatever dialect you are using
    .ConnectionString(...).ShowSql()

Once you have that set, NHibernate will write the queries it is executing and it may show up in your logging or unit tests or whatever, depending on how you have things setup.

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