File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Criteria API

 
Mateusz Kwasniewski
Greenhorn
Posts: 15
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Edvins Reisons
Ranch Hand
Posts: 364
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 49
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.....
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic