Criteria criteria = session.createCriteria(Employee.class); Listids = Arrays.asList(1, 2, 3); criteria.add(Restrictions.in("id", ids)); List employees = criteria.list();
Criteria criteria = session.createCriteria(Employee.class); criteria.add(Restrictions.isNotNull("name")); ListIn this example, we are fetching all employees whose name property is not null. The Restrictions.isNotNull() method takes one parameter: the property name to check. Overall, the org.hibernate.criterion Restrictions package provides various criterion objects that can be used to build complex queries for searching data in the database.employees = criteria.list();