TA的每日心情 | 开心 2021-3-12 23:18 |
---|
签到天数: 2 天 [LV.1]初来乍到
|
@Test
public void test8(){
List list = search("",0.0,1000.0);
Iterator it = list.iterator();
while(it.hasNext()){
Zfxx fw = (Zfxx)it.next();
System.out.println(fw.getDate()+"\t"+fw.getFwxx());
}
}
public List search(String key,Double zj1,Double zj2){
Session session = HibernateSessionFactory.getSession();
Criteria c = session.createCriteria(Zfxx.class);
if(!key.equals("")){
c.add(Restrictions.like("title", key,MatchMode.ANYWHERE));//关键字匹配方式:MatchMode.ANYWHERE,MatchMode.End,MatchMode.START,MatchMode.EXACT
}
if(zj1 != 0){
c.add(Restrictions.ge("zj", zj1)); //ge表示构造大于等于的查询
}
if(zj2 != 0){
c.add(Restrictions.le("zj", zj2)); //le表示构造小于等于的查询
}
c.addOrder(Order.asc("fwid"));
return c.list();
} |
|