The Hibernate Criteria query API is used to selectively find the entity from the persistence store (database). Here you will learn about the different ways of using the Criteria Query.
The Hibernate Criteria API is created in object orient way and Hibernate translate it into the actual SQL. It is the object orient and elegant alternative to the HQL for querying the objects. It provides many options to the developers.
The Hibernate Criteria query allows you to selectively fetch the data from database.
Creating a Criteria instance
First of we will learn how to create the an instance of Criteria?
The interface org.hibernate.Criteria is used to create the query and it repents the query against a particular persistent class. The Session object is used get the instance of Criteria.
Following code shows how you can get the instance of Criteria from the Session object:
Criteria criteria= session.createCriteria(Employee.class);
List employees = criteria.list();
Here are the example us of Criteria query:
Liked it! Share this Tutorial