Google News
logo
Java Hibernates - Interview Questions
What is the benefit of Hibernate Criteria API?
Hibernate provides Criteria API that is more object oriented for querying the database and getting results. We can't use Criteria to run update or delete queries or any DDL statements. It’s only used to fetch the results from the database using more object oriented approach.
 
Some of the common usage of Criteria API are :
 
* Criteria API provides Projection that we can use for aggregate functions such as sum(), min(), max() etc.
* Criteria API can be used with ProjectionList to fetch selected columns only.
* Criteria API can be used for join queries by joining multiple tables, useful methods are createAlias(), setFetchMode() and setProjection()
* Criteria API can be used for fetching results with conditions, useful methods are add() where we can add Restrictions.
* Criteria API provides addOrder() method that we can use for ordering the results.
Advertisement