• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Sorting objects in a collection

 
Saathvik Reddy
Ranch Hand
Posts: 228
  • Mark post as helpful
  • send pies
  • 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" />
</bag>

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" />
</bag>

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?

Thanks,
Srikanth.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic