hibernate 多条件与查询:Restrictions.or

为什么80%的码农都做不了架构师?>>>   hot3.png

Restrictions.or(Restrictions.like(),Restrictions.or(Restrictions.like,........))
里面的or可以无限加的.还是比较好用

Session session = getHibernateTemplate().getSessionFactory()
                .openSession();
        Criteria criteria = session.createCriteria(Film.class);
        List list = criteria.add(
            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;

转载于:https://my.oschina.net/xiangtao/blog/33567

你可能感兴趣的:(hibernate 多条件与查询:Restrictions.or)