hibernate Criteria(条件查询接口)

Criteria(条件查询接口)

复制代码
// 1.简单查询
List<Customer> list = session.createCriteria(Customer.class).list();
        
// 2.条件查询:
Criteria criteria = session.createCriteria(Customer.class);
criteria.add(Restrictions.eq("name","芙蓉"));
List<Customer> list = criteria.list();
        
// 3.分页查询:
Criteria criteria = session.createCriteria(Customer.class);
criteria.setFirstResult(3);
criteria.setMaxResults(3);
List<Customer> list = criteria.list();
posted @ 2017-05-29 11:05  洞玄巅峰  阅读(916)  评论(0编辑  收藏  举报