nhibernate 返回一个重复行
我正在使用 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
“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.