hql语句中like查询 对于 / ' " % 的处理
2008-05-30 17:56
302 查看
jdk1.5
public List searchByParas(String authId, String resourceId, Integer state, Integer value, String description) { log.debug("finding KiiUaResAuth instance by example"); try { description = description.replace("//", "//////").replace("%", "//%").replace("'", "''"); StringBuffer hql = new StringBuffer( "from KiiUaResAuth as k join k.id.resource as r where k.description like '%" + description + "%'"); if (authId != "") { hql.append(" and k.id.authId='" + authId + "'"); } if (resourceId != "") { hql.append(" and r.resourceId='" + resourceId + "'"); } if (state != null) { hql.append(" and k.resAuthState=" + state); } if (value != null) { hql.append(" and k.value=" + value); } if (description.indexOf("//") >= 0) { hql.append(" escape '/'"); } List results = getHibernateTemplate().find(hql.toString()); log.debug("find by example successful, result size: " + results.size()); List toresult = new ArrayList(); Object[] objlist = null; if (results.size() != 0) { for (int i = 0; i < results.size(); i++) { Object objs = results.get(i); objlist = (Object[]) objs; if (objlist[0] != null) { toresult.add((KiiUaResAuth) objlist[0]); } } } return toresult; } catch (RuntimeException re) { log.error("find by example failed", re); throw new SystemException("UA1202"); } }
相关文章推荐
- hql语句中like查询 对于 / ' " % 的处理
- hibernate里使用hql语句处理多表查询
- hql语句中用:号的时候怎么用like进行条件查询
- c#程序中使用"like“查询access数据库查询为空的问题
- jdbc对于模糊查询like语句嵌套变量的sql语句写法
- Java连接MySQL数据库实现用户名密码的验证方法 Java语句中sql查询语句'' ""作用
- '和"处理
- c#程序中使用"like“查询access数据库语句的问题
- SQL语句对于多表联合查询重复字段的特殊语法处理
- Hql语句模糊查询‘like’与中文问题
- Hql语句模糊查询‘like’与传递中文乱码问题
- sql语句中模糊查询Like中通配符的处理
- c#程序中使用"like“查询access数据库查询为空的问题
- mysql like 查询 有单引号的处理办法。org.hibernate.QueryException: expecting ''', found '<EOF>' [SELECT DISTINCT
- condition = "select * from book where" +field+ "like '%" +keyWord+ "%'"; 这个select where 语句错误?
- R语言使用ODBC连接数据库PostgreSQL查询语句中含有""处理方法
- Oracle中like查询下划线等特殊字符的处理
- ASP中查询日期一般查询用'单引号,在这里查询日期型用#号
- [中文]React:"don't fuck it up like Google did with Angular"
- hibernate查询语句--HQL