两个条件或查询:
Restrictions.or(Restrictions.in("username",list1),Restrictions.idEq(1));
三个或多个条件查询:(使用嵌套方式)
criteria.add(Restrictions.or(
Restrictions.in("username",list1),
Restrictions.or(Restrictions.idEq(3),Restrictions.idEq(4))
)
);
Restrictions.or(Restrictions.like(),Restrictions.or(Restrictions.like,........))
里面的or可以无限加的.还是比较好用
Session session = getHibernateTemplate().getSessionFactory()
.openSession();
Criteria criteria = session.createCriteria(Film.class);
List
Restrictions.or(Restrictions.like("description", key,MatchMode.ANYWHERE),
Restrictions.or(Restrictions.like("name", key,MatchMode.ANYWHERE),
Restrictions.or( Restrictions.like("direct", key,MatchMode.ANYWHERE),
Restrictions.or(Restrictions.like("mainplay",key,MatchMode.ANYWHERE),
Restrictions.like("filearea", key,MatchMode.ANYWHERE)))))).list();
session.close();
return list;