以下是我的代码:
String hsql = "from Customer c where c.name='测试' ";
IQuery query = _session.CreateQuery(hsql);
query.List();执行时,不抛出异常,但不返回查询结果(应根据条件c.name='测试'返回)
这是为hsql生成的sql NHibernate:
select customer0_.CUSTOMER_NO as CUSTOMER1_, customer0_.CODE as CODE9_, customer0_.NAME as NAME9_, customer0_.STATUS as STATUS9_, customer0_.LAST_OPE RATOR_NO as LAST5_9_
from CUSTOMER customer0_ where (customer0_.NAME='????')hsql中的汉字“测试”变成了“?”在sql中。
当我通过Nhibernate添加客户时,汉字保存成功。这里的问题只出现在我使用CreateQuery搜索文本的时候。任何帮助都将不胜感激。
发布于 2012-06-07 21:59:06
你能用一个参数来试一下吗?
String hsql = "from Customer c where c.name=:name";
IQuery query = _session.CreateQuery(hsql).SetString("name", "测试");
query.List();https://stackoverflow.com/questions/10933144
复制相似问题