Following is my code:
String hsql = "from Customer c where c.name='测试' ";
IQuery query = _session.CreateQuery(hsql);
query.List();
when executing, no exception thrown, but no query result return (they should return based the condition c.name='测试'
)
this is the sql NHibernate generate for the hsql:
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='????')
The chinese characters '测试' in hsql become '????' in sql.
The chinese characters are saving successfully when I am adding a customer through Nhibernate. Here the issue is only when I am searching a text using CreateQuery. Any help will be appreciated.
Can you try it using a parameter?
String hsql = "from Customer c where c.name=:name";
IQuery query = _session.CreateQuery(hsql).SetString("name", "测试");
query.List();
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.