nhibernate 返回一个重复行

发布于 2024-10-01 12:09:34 字数 599 浏览 0 评论 0原文

我正在使用 nhibernate 和 mysql 数据库。我正在尝试从一张表中提取简单的数据。我创建了我的实体和映射。我能够与数据库交谈。它从数据库表中提取正确的行数,但每一行都是表中第一行的重复。 (表中有 51 行。返回 51 行,但每一行都是重复的)。我把它设置为显示sql,并且sql是正确的。

这是我的映射文件的片段 -

<?xml version="1.0" encoding="utf-8" ?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" assembly="myAssembly" namespace="MyProject.Models.Entities">
  <class name="myClass">
    <id name="id">
      <generator class="identity" />
    </id>

    <property name="column2" />
    <property name="column3" />
....

有人知道会发生什么吗?感谢您的任何想法。

I am using nhibernate with a mysql db. I am trying to do a simple data extraction from one table. I created my entity and my mappings. I am able to talk to the db. It is pulling the correct number of rows from the db table, but each row is a duplicate of the first row in the table. (I have 51 rows in the table. 51 rows are being returned, but each row is a duplicate). I have it set to show sql, and the sql is correct.

Here is a snippet of my mapping file -

<?xml version="1.0" encoding="utf-8" ?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" assembly="myAssembly" namespace="MyProject.Models.Entities">
  <class name="myClass">
    <id name="id">
      <generator class="identity" />
    </id>

    <property name="column2" />
    <property name="column3" />
....

Does anyone have any idea what might be going on? Thanks for any thoughts.

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

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

发布评论

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

评论(1

悲凉≈ 2024-10-08 12:09:34

“id”真的是您实体的 id 吗?

NHibernate 将为具有该 id 的所有返回行返回相同的对象。

Is "id" really the id of your entity?

NHibernate will return the same object for all returned rows with that id.

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