第一种:
@Override
public List 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 applies=(List)this.getHibernateTemplate().find(hql.toString());
return applies;
}
第二种:
@Override
public List 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 applies=(List)this.getHibernateTemplate().find(hql);
return applies;
}
标签:语句,String,app,List,拼接,hql,applies,apstate
来源: https://www.cnblogs.com/annuush/p/10967083.html