top button
Flag Notify
    Connect to us
      Site Registration

Site Registration

What is the benefit of Hibernate Criteria API?

0 votes
770 views
What is the benefit of Hibernate Criteria API?
posted Sep 11, 2017 by Rajesh Jk

Share this question
Facebook Share Button Twitter Share Button LinkedIn Share Button

1 Answer

0 votes

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.

answer Sep 12, 2017 by Sourav Kumar
...