How to Ordering the results in the Hibernate by R4R Team

We can set as the given code is below. With the help we can do the results using org.hibernate.criterion.Order.


As we given below:


List student = session.createCriteria(Student.class)

    .add( Restrictions.like("name", "G%")

    .addOrder( Order.asc("name") )

    .addOrder( Order.desc("age") )

    .setMaxResults(50)

    .list();

List student = session.createCriteria(Studnet.class)

    .add( Property.forName("name").like("G%") )

    .addOrder( Property.forName("name").asc() )

    .addOrder( Property.forName("age").desc() )

    .setMaxResults(50)

    .list();

Leave a Comment:
Search
Categories
R4R Team
R4Rin Top Tutorials are Core Java,Hibernate ,Spring,Sturts.The content on R4R.in website is done by expert team not only with the help of books but along with the strong professional knowledge in all context like coding,designing, marketing,etc!