NHibernate 是否应该为不带引号的 GUID 参数生成 SQL?
SQL Server 2008 R2 Express。 NHibernate 2.1.2.4。
我得到如下 SQL:
SELECT customer0_.Id as Id1_0_
FROM customers customer0_
WHERE customer0_.Id=@p0;
@p0 = 11111111-1111-1111-1111-111111111111
...即使其中有具有该 ID 的客户,它也会返回 0 条记录。
SQL Server 列数据类型是 UNIQUEIDENTIFIER。
配置如下:
<property name="connection.provider">NHibernate.Connection.DriverConnectionProvider</property>
<property name="connection.driver_class">NHibernate.Driver.SqlClientDriver</property>
<property name="dialect">NHibernate.Dialect.MsSql2005Dialect</property>
类的
配置如下
<id name="_id" column="Id" type="Guid" access="field" unsaved-value="00000000-0000-0000-0000-000000000000" >
<generator class="guid.comb" />
</id>
在各种 tuts 的帮助下,我第一次通过此方法。我已经把所有事情都经历过好几次了,但没有任何快乐。任何想法这里有什么问题/遗漏吗?蒂亚!
Sql Server 2008 R2 Express. NHibernate 2.1.2.4.
I get SQL like:
SELECT customer0_.Id as Id1_0_
FROM customers customer0_
WHERE customer0_.Id=@p0;
@p0 = 11111111-1111-1111-1111-111111111111
...which returns 0 records even though there is Customer in there with that Id.
The SQL Server column datatype is UNIQUEIDENTIFIER.
<session-factory>
configured as follows:
<property name="connection.provider">NHibernate.Connection.DriverConnectionProvider</property>
<property name="connection.driver_class">NHibernate.Driver.SqlClientDriver</property>
<property name="dialect">NHibernate.Dialect.MsSql2005Dialect</property>
Class's <id>
configured as follows
<id name="_id" column="Id" type="Guid" access="field" unsaved-value="00000000-0000-0000-0000-000000000000" >
<generator class="guid.comb" />
</id>
Forging my way through this for the first time, w/ the help of various tuts. I've been over everything several times but no joy. Any ideas what is wrong/missing here? TYIA!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这似乎是正确的。根据 this "我们必须记住,Guid 不是字符串,即使我们认为 Guid 是一个 16 字节的数据结构。 ”。所以我不确定为什么你没有得到你期望的结果,但我认为生成的 SQL 没有引号是正确的。
This seems correct. According to this "we must remember that a Guid is not a string even thought that's how we see them. A Guid is a 16-byte data structure." So I'm not sure why you are not getting back the results you expect, but I think the generated SQL is correct in not having the quotes.