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(绝对是不可能的).