首页 > 代码库 > hibernate Criteria(条件查询接口)

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();

hibernate Criteria(条件查询接口)