• 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 ...
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Jeanne Boyarsky
  • Tim Cooke
  • Liutauras Vilda
  • paul wheaton
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Frits Walraven
  • Piet Souris
  • Himai Minh

Sorting objects in a collection

Ranch Hand
Posts: 228
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Ranchers,

I have a many-to-many collection like so:

<bag name="organizations" table="claim_user_orgs" lazy="true" >
<key column="claim_user_id" />
<many-to-many class="CID.IPath.NewBusinessLayer.organization, CID.IPath.NewBusinessLayer" column="organization_id" />

where claim_user_orgs is an association table, and just has 2 columns: claim_user_id and organization_id.

I want the collection property "organizations" of the claim_user object to return the list of organizations sorted by organization_name, so I did this:

<bag name="organizations" table="claim_user_orgs" lazy="true" order-by="client_name asc" >
<key column="claim_user_id" />
<many-to-many class="CID.IPath.NewBusinessLayer.organization, CID.IPath.NewBusinessLayer" column="organization_id" />

However, this gives me an error, because there is no column called client_name in the association table.

How can I sort a many-to-many collection? And where would I put the order-by clause?

Oh the stink of it! Smell my tiny ad!
Free, earth friendly heat - from the CodeRanch trailboss
    Bookmark Topic Watch Topic
  • New Topic