Hibernate Tutorials/
« Previous | 1 | 2 | 3 | Next »
The Criteria API provides the org.hibernate.criterion.Order class to sort your result set in either ascending or descending order, according to one of your object's properties. This example demonstrates how you would use the Order class to sort the result set:

Criteria cr =session.createCriteria(Employee.class);
// To get records having salary more than 2000
cr.add(Restrictions.gt("salary",2000));

// To sort records in descening order
crit.addOrder(Order.desc("salary"));

// To sort records in ascending order
crit.addOrder(Order.asc("salary"));

List results =cr.list();
« Previous | 1 | 2 | 3 | Next »


copyright © 2014 - all rights riserved by javatechnologycenter.com