• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Retereive data by ORDER BY

 
Ranch Hand
Posts: 82
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Any idea how I can achieve this. Thanks
 
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
reply
    Bookmark Topic Watch Topic
  • New Topic