In my project, I used Hibernate2.0 with struts framework.
In hibernate2.0, I used to get the records by using Criteria.
Now I have a problem in sorting.
For example, private abstract class Book { Integer bookId; String bookName; } private abstract class customer { Integer customerId; String customerName; Book cusomerBookId; }
In this example,if I want to sort by customerId,customerName, I use
criteria.addOrder(Order.asc(customerId));
criteria.addOrder(Order.asc(customerName));
When I would like to sort by using book Name, I use
criteria.addOrder(Order.asc(cusomerBookId.bookName));
It does not sort,Rather If I give
criteria.addOrder(Order.asc(cusomerBookId));
Like that, then It sorts by bookId
Now How to sort by cusomerBookId.bookName. Is it possible to sort like that?
If possibe how to do it? Kindly explain me.
|