以下是我的代码:
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 搜索文本时。任何帮助将不胜感激。