`

hibernate 多条件查询

阅读更多
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());
}
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics