关于hibernate占位符中使用like及相关注意事项
?
,而只需要? orderby :hostName , 然后在占位符里面设置这个hostName,不然会报错。
StringBuilder hql = new StringBuilder(0); hql.append( "from TblHost h where h.vmHost.hostID in (select t.hostID from TblHost t" ); hql.append( " where t.ishpvhost=1 and t.ccmData.id in (select c.id from CcmData c " ); hql.append( " where c.pathid like " ); hql.append( ":id" ); hql.append( " or c.id= " ); hql.append( ":id2" ); hql.append( ")) " ); hql.append(strHql); List<TblHost> tempList = null ; try { tempList = this .getHibernateTemplate().findByNamedParam(hql.toString(), new String[] { "id" , "id2" }, new Object[] { "%" + id + "%" , new Integer(id)}); } catch (DataAccessException e) { // 这里进行 usm 的日志记录及相关处理 } ?
?
?
???????????????????????????????????????????????? 田军sdy645 tKF25401
???????????????????????????????????????????????? 2010-04-21