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