• 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
  • Tim Cooke
  • Devaka Cooray
  • Ron McLeod
  • Jeanne Boyarsky
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Piet Souris
  • Carey Brown
  • Tim Holloway
Bartenders:
  • Martijn Verburg
  • Frits Walraven
  • Himai Minh

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
 
Ruth Stout was famous for gardening naked. Just like this tiny ad:
the value of filler advertising in 2021
https://coderanch.com/t/730886/filler-advertising
reply
    Bookmark Topic Watch Topic
  • New Topic