hibernate 多条件查询
程序员文章站
2024-03-03 16:45:10
...
public List<Client> 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());
}