第一种: @Override public ListApply findByState(String apstate) { StringBuffer hql= new StringBuffer(); hql.append("from Apply app where 1=1"); if (apstate.length() != 0 apstate!=null){ hql.append(" and app.appState like ‘%"+apstate+"
第一种:
@Override
public List<Apply> findByState(String apstate) {
StringBuffer hql= new StringBuffer();
hql.append("from Apply app where 1=1");
if (apstate.length() != 0 && apstate!=null){
hql.append(" and app.appState like ‘%"+apstate+"%‘");
}
List<Apply> applies=(List<Apply>)this.getHibernateTemplate().find(hql.toString());
return applies;
}
第二种:
@Override public List<Apply> findByState2(String apstate) { String hql= "from Apply app where 1=1"; if (apstate.length() != 0 && apstate!=null){ hql=hql+" and app.appState like ‘%"+apstate+"%‘"; } List<Apply> applies=(List<Apply>)this.getHibernateTemplate().find(hql); return applies; }