-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 
Author Message
 Post subject: nhibernate many-to-many with order-by
PostPosted: Fri Nov 23, 2007 2:41 pm 
Newbie

Joined: Tue Sep 25, 2007 6:43 am
Posts: 16
Hello,

I have a m:n mapping and do not know how to order the results.

Here is the mapping for class Category:
Code:
<class...>
...
<bag name="Products"
    table="ProductCategory"
    cascade="save-update"
    lazy="true" order-by="Name">
   <key column="CategoryID"/>
   <many-to-many class="Product"
      column="ProductID"/>
</bag>
</class>


Now, ordering on "Name" does not work, of course, because that's a column in the "Product" table and not on the association table "ProductCategory". How can I reach the right table from the mapping?

Thanks,
Jan


Top
 Profile  
 
 Post subject:
PostPosted: Tue Dec 04, 2007 11:17 am 
Beginner
Beginner

Joined: Thu Oct 26, 2006 4:45 am
Posts: 39
Why not order in your code?

Like you probably now have an unordered NHibernate list in your Category class:

IList<Product> ProductList...

why not present a:

IList<Product> ProductsByName
{
return ProductList.Sort(new CompareProductrByName(...)
}


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.