日期:2014-05-18  浏览次数:20644 次

ibatis问题:急!!!一条sql语句控制台正常返回结果,但是在ibatis中却返回空
有这样一条sql语句:
select   a.id   as   id,   u1.user_name   as   sndr_name,   u2.user_name   as   rcvr_name,   a.grade   as   grade,   a.status   as   status,   a.be_read   as   be_read,   a.send_time   as   send_time,   a.summary   as   summary         from   assignment   a,   user   u1,   user   u2      
where   u1.user_name   like   %宋%   and   a.sndr_id   =   u1.user_id   and   u2.user_id   =   a.rcvr_id;
在控制台执行返回六条记录,把它写在ibatis的配置文件中却返回零条记录.我观察了以下问题发生在   "u1.user_name   like   %宋% "这里,把这段去掉,则在ibatis中也能正常返回记录.
请问:熟悉ibatis的朋友,这是什么问题呢?该如何解决?谢谢!!!

------解决方案--------------------
中文编码的问题!看看你的文件保存的格式,还有数据库的存取格式!最好全用UTF-8
OR GB2312

------解决方案--------------------
where u1.user_name like like '%$user_name$% ',变量要用$,而不能用#