| Author |
Criteria API
|
Mateusz Kwasniewski
Greenhorn
Joined: Apr 18, 2006
Posts: 15
|
|
I'd like to get a list of subcategories in order (asc or desc) specified by the number of books in a subcategory. Can anyone help me to figure out how can I do it using Hibernate Criteria API? Here is the code of the Subcategory class: Thanks in advance
|
SCJP5 - 90%<br />SCWCD - 91%
|
 |
Edvins Reisons
Ranch Hand
Joined: Dec 11, 2006
Posts: 364
|
|
What if you approach this matter from the Book end of the association? Group them by Subcategory and order by rowCount.
|
 |
saranga rao
Ranch Hand
Joined: Apr 24, 2007
Posts: 49
|
|
hi , Might it look like this....... List lst = session.createCriteria(SubCategories.class).createAllias("Book","bk").add(Expression.eq("bk.id",id).add(Order asc); May there will be change in the Allias name but the query returns list of SubCategories.....
|
 |
 |
|
|
subject: Criteria API
|
|
|