Assuming we have a TravelReview table with City names as column "title"
Criteria criteria =
session.createCriteria(TravelReview.class);
List review =
criteria.add(Restrictions.eq("title", "Mumbai")).list();
System.out.println("Using equals: " + review);
We can add restrictions to the criteria by chaining them as follows:
List reviews = session.createCriteria(TravelReview.class)
.add(Restrictions.eq("author", "John Jones"))
.add(Restrictions.between("date",fromDate,toDate))
.add(Restrictions.ne("title","New York")).list();