繁体中文
设为首页
加入收藏
当前位置:JSP技术首页 >> 资料/其它 >> hibernate in 查询

hibernate in 查询

2005-03-15 08:00:00  作者:  来源:互联网  浏览次数:0  文字大小:【】【】【
简介:StringBuffer buf = new StringBuffer(); if (!forObject) { buf.append("select count(*) "); } buf.append("from Agent agent where 1=1 "); String gradeId = (String)conditions.get("gradeId"); ...
关键字:hibernate 查询 in

StringBuffer buf = new StringBuffer(); if (!forObject) { buf.append("select count(*) "); } buf.append("from Agent agent where 1=1 ");

String gradeId = (String)conditions.get("gradeId"); if(gradeId != null && !gradeId.equals("") && gradeId != ""){ buf.append(" and agent.gradeId=").append(gradeId); }

buf.append(" and agent.agentId in (:agentIds) ");

Query query = sess.createQuery(buf.toString()); List ids = CommisionInfoDelegateExt.findAgentIdList(conditions); System.out.println("ids.length=" + ids.size()); query.setParameterList("agentIds", ids);

当ids长度为0(空记录)时,query.list()出错.没办法,现在在ids.add("-1"),塞入一条绝对不存在的记录id(绝对是不可能的).

责任编辑:admin
相关文章