Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Retereive data by ORDER BY

 
Mike Boota
Ranch Hand
Posts: 82
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi I need a small help in getting the data as per the order it's entered in the table. I am building a menu that has sub-menus.
In SUB_MENU table I also have a order_by column and in my hbm.xml file I specify orderby on that column it returns me data in correct order.

ParentMenu does not have order_by column how can I get the data ordered by on id column for my ParentMenu i.e. a sequence. Or do I need a order_by column in ParentMenu table and then specify ordyby on that column too.




Thanks
 
Mike Boota
Ranch Hand
Posts: 82
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Any idea how I can achieve this. Thanks
 
newbie awo
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What happens if you try adding something like sort="MyComparatorClass" to the set of SubMenus (in the ParentMenu mapping)?

(Then you could implement a class which implements java.util.Comparator and whose compareTo method allows the SubMenu objects to be sorted by the property that maps to your order-by column.)
[ September 06, 2006: Message edited by: newbie awo ]
 
Mike Boota
Ranch Hand
Posts: 82
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
My Sub Menu is in order as I have

<set name="subMenu" table="SUB_MENU" order-by="ORDER_BY">

But the issue is how to get the data ordered by id column on my Parent Menu. id is a number field in my Menu Table. That is my Parent menu is not ordered. e.g. in my Parent Menu table If I have the following data

A 32
B 2
C 4

it shows up in that order, but I would like to see it in the following order i.e. order by id

B
C
A

Thanks
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic