hibernate 多条件查询
[code="java"]public List searchClients(String clientName, String tel, String identityNo) { StringBuffer sb = new StringBuffer("from Client c where 1=1"); if(clientName != null && !"".equals(clientName) ){ sb.append("and c.name like '%" + clientName + "%'"); } if(tel != null && !"".equals(tel)){ sb.append("and c.tel = " + tel); } if(identityNo != null && !"".equals(identityNo)){ sb.append("and c.identityNo = " + identityNo); } return clientDao.searchClients(sb.toString()); }[/code]