Criteria criteria = session.createCriteria(Product.class); criteria.add(Restrictions.gt("price", 10)); Listproducts = criteria.list();
Criteria criteria = session.createCriteria(Product.class); criteria.add(Restrictions.like("name", "%shoes%")); Listproducts = criteria.list();
Date date = // some date Criteria criteria = session.createCriteria(Order.class); criteria.add(Restrictions.gt("createdAt", date)); ListIn the above examples, we used the following methods: - `gt`: Creates a "greater than" restriction. - `like`: Creates a "like" restriction, which matches a string pattern. - `createdAt`: A property of the `Order` object, which is used to filter the results. Overall, the org.hibernate.criterion Restrictions package library provides a useful set of methods that can make querying a database using Hibernate more efficient and easy to read.orders = criteria.list();