public List getOrganizationInfoByLikeName(
String likeName) throws UnsupportedEncodingException {
//String name = new String(likeName.getBytes("UTF-8"),"GBK");
String sql = "from OrganizationInfo org where org.name like '"+likeName+"%'";
return getHibernateTemplate().find(sql);
}
拼出来的sql条件语句字段是乱码导致查询不到记录,怎么处理?
Hibernate: select organizati0_.ID as ID, organizati0_.CODE as CODE10_, organizati0_.NAME as NAME10_, organizati0_.YJ_ORGANIZATION_CODE as YJ4_10_, organizati0_.LOGIC_CODE as LOGIC5_10_, organizati0_.ORG_TYPE as ORG6_10_, organizati0_.ORG_PERIOD_TYPE as ORG7_10_, organizati0_.PARENT_ORG_ID as PARENT8_10_, organizati0_.FITECH_FILLER as FITECH9_10_, organizati0_.FITECH_CHECKER as FITECH10_10_, organizati0_.FITECH_PRINCIPAL as FITECH11_10_, organizati0_.IS_DELETED as IS12_10_, organizati0_.conver_code1 as conver13_10_, organizati0_.conver_code2 as conver14_10_, organizati0_.conver_code3 as conver15_10_, organizati0_.ORG_FLAG as ORG16_10_, organizati0_.SUM_FLAG as SUM17_10_, organizati0_.RH_ORG_CODE as RH18_10_, organizati0_.RH_LOC_CODE as RH19_10_, organizati0_.RH_SYSTEM_CODE as RH20_10_, organizati0_.RHN_ORG_CODE as RHN21_10_, organizati0_.RHN_SYSTEM_CODE as RHN22_10_ from ORGANIZATION_INFO organizati0_ where organizati0_.NAME like '????%'
SQL String 乱码 Hibernate
------解决方案--------------------
界面上面的编码格式是什么呢,是不是和后台的不一致啊,跟踪进去看看是什么地方变成乱码的,找到问题原因就好办了
------解决方案--------------------
String name = new String(likeName.getBytes("iso8859-1"),"GBK");
------解决方案--------------------
前后台编码统一就好了
------解决方案--------------------
String name = new String(likeName.getBytes("iso8859-1"),"GBK");