Hibernate: ORDER BY using Criteria API.

Hibernate: ORDER BY using Criteria API.

How to display record in order using Criteria API?

View Answers

May 29, 2012 at 6:51 PM

Hibernate Criteria API provides an easy way of building dynamic query on the persistence database.

The hibernate criteria API is very Simplified API for fetching data from Criterion objects. The criteria API is an alternative of HQL (Hibernate Query Language) queries. It is more powerful and flexible for writing tricky criteria functions and dynamic queries.

You can easily order your record by using Criteria API either in ascending order or in descending order.

Example- In ascending order-

Session session = sessionFactory.openSession();

        Criteria criteria = session.createCriteria(Employee.class);
        criteria.addOrder(Order.asc("name"));

In descending order-

Criteria criteria = session.createCriteria(Employee.class);
        criteria.addOrder(Order.desc("name"));

Ads









Related Tutorials/Questions & Answers:
Hibernate: ORDER BY using Criteria API.
Hibernate: ORDER BY using Criteria API.  How to display record in order using Criteria API?   Hibernate Criteria API provides an easy way.... You can easily order your record by using Criteria API either in ascending order
Retrieve data using Criteria api
Retrieve data using Criteria api  import org.hibernate.Session; import org.hibernate.SessionFactory; import org.hibernate.Query; import...=configuration.buildSessionFactory(); Session s=sf.openSession(); Criteria criteria
Advertisements
Using criteria for multiple tables
Using criteria for multiple tables  How to join more than three tables,those tables must be maintain primary key relation ship using Hql criteria & projections
Using criteria for multiple tables
Using criteria for multiple tables  How to join more than three tables,those tables must be maintain primary key relation ship using Hql criteria & projections
Using sum() in hibernate criteria.
Using sum() in hibernate criteria.  How to calculate sum() in hibernate criteria by using projection?   You can calculate sum of any numeric value in hibernate criteria by using projection. Projection is an interface
What is criteria API?
What is criteria API?  Hi, What is criteria API? Thanks,  ... on the persistence database. The hibernate criteria API is very Simplified API for fetching data from Criterion objects. The Hibernate Criteria API contains Restriction class
criteria api
criteria api  what is the purpose of Restrictions class   Using Restrictions class, we can narrow the result of our query.Here are some restrictions that can also be use to narrow our Criteria query result
Hibernate Criteria API
criteria functions and dynamic queries. Using Criteria API to create...Hibernate Criteria API The API (Application Programming Interface... on the persistence database. The hibernate criteria API is very Simplified API for fetching
Hibernate criteria query using Max()
Hibernate criteria query using Max()  What is Hibernate criteria query using Max()?   You can find out maximum value in hibernate criteria... in ?org.hibernate.criterion?. For using Projection object in our Criteria, we have to call
Hibernate criteria query using Min().
Hibernate criteria query using Min().  How to find minimum value in Hibernate criteria query using Projection?   You can find out minimum value in hibernate criteria by using projection. Projection is an interface
Hibernate criteria query using avg()
Hibernate criteria query using avg()  How to calculate average in Hibernate criteria query using Projection?   You can calculate average of any numeric values in hibernate criteria by using projection. Projection
Joining tables using criteria
Joining tables using criteria  How do i join more than three tables and retrieve one column from parent table and count of unique values in a single column from child table,the joined tables must be maintain primary key
Hibernate criteria example using struts2
Hibernate criteria example using struts2 This hibernate criteria example using... API is used for creating dynamic query. With the help of criteria, you can create query without HQL. In this hibernate criteria example using struts2, we
Case-insensitive ordering using Hibernate Criteria.
Case-insensitive ordering using Hibernate Criteria.  What is Case-insensitive ordering in Hibernate Criteria
Case-sensitive equals using Hibernate Criteria.
Case-sensitive equals using Hibernate Criteria.  How to check for case sensitive equals in Hibernate criteria?   package net.roseindia.main... : 220000 Date of Join : 2001-02-03 00:00:00.0 Description : Hibernate Criteria API
Case-insensitive equals using Hibernate Criteria.
Case-insensitive equals using Hibernate Criteria.  How to use Case-insensitive equals with Hibernate Criteria?   The Case Insensitive... = sessionFactory.openSession(); Criteria criteria = session.createCriteria
How to get unique list in Hibernate using Criteria Query?
How to get unique list in Hibernate using Criteria Query?  Hi, Share me the example code for getting Unique List in Hibernate through Criteria Query? Thanks
Hibernate Criteria
the different ways of using the Criteria Query. The Hibernate Criteria API...Hibernate Criteria - Learn the Hibernate Criteria API and master the Hibernate framework The Hibernate Criteria query API is used to selectively find
criteria
criteria  Hi how to find highest salary of an employee using criteria in hibernate?   Here is a code that finds the maximum salary among the employees from the database using Hibernate Criteria. Criteria criteria
uSING JAVA API
uSING JAVA API  How to extract Quickbooks online data using Quickbooks api( Rest ApI) write in java code ? 1.register company account 2..register application 3.get apptoken,consumer key,consumer screte 4.how can i
Maven dependency for net.n2oapp.criteria - criteria-api version 7.12.3 is released. Learn to use criteria-api version 7.12.3 in Maven based Java projects
of criteria-api released The developers of   net.n2oapp.criteria - criteria..., the released version of  net.n2oapp.criteria - criteria-api library is 7.12.3. Developer can use this version ( net.n2oapp.criteria - criteria-api version
Maven dependency for net.n2oapp.criteria - criteria-api version 7.12.6 is released. Learn to use criteria-api version 7.12.6 in Maven based Java projects
of criteria-api released The developers of   net.n2oapp.criteria - criteria..., the released version of  net.n2oapp.criteria - criteria-api library is 7.12.6. Developer can use this version ( net.n2oapp.criteria - criteria-api version
Maven dependency for net.n2oapp.criteria - criteria-api version 7.12.9 is released. Learn to use criteria-api version 7.12.9 in Maven based Java projects
of criteria-api released The developers of   net.n2oapp.criteria - criteria..., the released version of  net.n2oapp.criteria - criteria-api library is 7.12.9. Developer can use this version ( net.n2oapp.criteria - criteria-api version
Maven dependency for net.n2oapp.criteria - criteria-api version 7.12.12 is released. Learn to use criteria-api version 7.12.12 in Maven based Java projects
of criteria-api released The developers of   net.n2oapp.criteria - criteria..., the released version of  net.n2oapp.criteria - criteria-api library is 7.12.12. Developer can use this version ( net.n2oapp.criteria - criteria-api version
Maven dependency for net.n2oapp.criteria - criteria-api version 7.12.15 is released. Learn to use criteria-api version 7.12.15 in Maven based Java projects
of criteria-api released The developers of   net.n2oapp.criteria - criteria..., the released version of  net.n2oapp.criteria - criteria-api library is 7.12.15. Developer can use this version ( net.n2oapp.criteria - criteria-api version
Maven dependency for net.n2oapp.criteria - criteria-api version 7.13.2 is released. Learn to use criteria-api version 7.13.2 in Maven based Java projects
of criteria-api released The developers of   net.n2oapp.criteria - criteria..., the released version of  net.n2oapp.criteria - criteria-api library is 7.13.2. Developer can use this version ( net.n2oapp.criteria - criteria-api version
Maven dependency for net.n2oapp.criteria - criteria-api version 7.13.7 is released. Learn to use criteria-api version 7.13.7 in Maven based Java projects
of criteria-api released The developers of   net.n2oapp.criteria - criteria..., the released version of  net.n2oapp.criteria - criteria-api library is 7.13.7. Developer can use this version ( net.n2oapp.criteria - criteria-api version
Maven dependency for net.n2oapp.criteria - criteria-api version 7.13.10 is released. Learn to use criteria-api version 7.13.10 in Maven based Java projects
of criteria-api released The developers of   net.n2oapp.criteria - criteria..., the released version of  net.n2oapp.criteria - criteria-api library is 7.13.10. Developer can use this version ( net.n2oapp.criteria - criteria-api version
Maven dependency for net.n2oapp.criteria - criteria-api version 7.15.0 is released. Learn to use criteria-api version 7.15.0 in Maven based Java projects
of criteria-api released The developers of   net.n2oapp.criteria - criteria..., the released version of  net.n2oapp.criteria - criteria-api library is 7.15.0. Developer can use this version ( net.n2oapp.criteria - criteria-api version
Maven dependency for net.n2oapp.criteria - criteria-api version 7.15.3 is released. Learn to use criteria-api version 7.15.3 in Maven based Java projects
of criteria-api released The developers of   net.n2oapp.criteria - criteria..., the released version of  net.n2oapp.criteria - criteria-api library is 7.15.3. Developer can use this version ( net.n2oapp.criteria - criteria-api version
Maven dependency for net.n2oapp.criteria - criteria-api version 7.15.6 is released. Learn to use criteria-api version 7.15.6 in Maven based Java projects
of criteria-api released The developers of   net.n2oapp.criteria - criteria..., the released version of  net.n2oapp.criteria - criteria-api library is 7.15.6. Developer can use this version ( net.n2oapp.criteria - criteria-api version

Ads