hibernate中用hql语句判断一个字符串是否为空
publicPagingList<Complaint>searchList(Timestamptime1,Timestamptime3,intdepartmentid,i...
public PagingList<Complaint> searchList(Timestamp time1, Timestamp time3,
int departmentid, int userid, int departmentid1,
int questionSortid, int handleSortid, int yesno, String filename2) {
QueryHelper qh=new QueryHelper("select distinct c from Complaint as c,Department as d,QuestionSort as q,HandleSort as h,User as u");
qh.setParam(true, "c.type=3");
qh.setParam(time1==null?false:true, "c.time>=? ",time1);
qh.setParam(time3==null?false:true, "c.time<=?",time3);
qh.setParam(departmentid==-1?false:true,"c.department.id=?",departmentid);
qh.setParam(yesno==-1?false:true,"c.yesno=?",yesno);
qh.setParam(userid==-1?false:true, "u.id in elements(c.users) and u.id=?",userid);
qh.setParam(departmentid1==-1?false:true,"d.id in elements(c.departments) and d.id=?",departmentid1);
qh.setParam(questionSortid==-1?false:true,"q.id in elements(c.questionSorts) and q.id=?",questionSortid);
qh.setParam(handleSortid==-1?false:true,"h.id in elements(c.handleSorts) and h.id=?",handleSortid);
qh.setParam(filename2.equals("-1")?false:true, "c.filename2 is ?",filename2);
return this.entityDAO.getPagingList(qh.getQuerySql(), 10, qh.getParams());
}
重点是qh.setParam(filename2.equals("-1")?false:true, "c.filename2 is ?",filename2);写的对吗???为什么就是查不出来 展开
int departmentid, int userid, int departmentid1,
int questionSortid, int handleSortid, int yesno, String filename2) {
QueryHelper qh=new QueryHelper("select distinct c from Complaint as c,Department as d,QuestionSort as q,HandleSort as h,User as u");
qh.setParam(true, "c.type=3");
qh.setParam(time1==null?false:true, "c.time>=? ",time1);
qh.setParam(time3==null?false:true, "c.time<=?",time3);
qh.setParam(departmentid==-1?false:true,"c.department.id=?",departmentid);
qh.setParam(yesno==-1?false:true,"c.yesno=?",yesno);
qh.setParam(userid==-1?false:true, "u.id in elements(c.users) and u.id=?",userid);
qh.setParam(departmentid1==-1?false:true,"d.id in elements(c.departments) and d.id=?",departmentid1);
qh.setParam(questionSortid==-1?false:true,"q.id in elements(c.questionSorts) and q.id=?",questionSortid);
qh.setParam(handleSortid==-1?false:true,"h.id in elements(c.handleSorts) and h.id=?",handleSortid);
qh.setParam(filename2.equals("-1")?false:true, "c.filename2 is ?",filename2);
return this.entityDAO.getPagingList(qh.getQuerySql(), 10, qh.getParams());
}
重点是qh.setParam(filename2.equals("-1")?false:true, "c.filename2 is ?",filename2);写的对吗???为什么就是查不出来 展开
- 你的回答被采纳后将获得:
- 系统奖励15(财富值+成长值)+难题奖励30(财富值+成长值)
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询