ITeye博客

hibernate 多条件查询

oyprunner · 2009-10-30 17:34 · Hibernate · C · Java · C++ · C# · Hibernate · Markdown

[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]

评论(0)

暂无评论。

评论功能维护中,当前仅展示历史评论。