-->
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.  [ 1 post ] 
Author Message
 Post subject: Aggregate Order By on a <Map> Collection using NHibern
PostPosted: Wed Sep 26, 2007 10:56 am 
Newbie

Joined: Wed Sep 26, 2007 10:25 am
Posts: 1
I am trying to set the order by clause to the count of the Map collection via HQL. My mapping file looks like this

The Orders Class
<class name="Orders" table="Orders" >
<id name="Id" type="Int64">
<generator class="identity" />
</id>
<property column="Title" type="String" name="Title" length="400" />
<map name="Details" cascade="none" lazy="false">
<key column="OrderId" />
<index column="OrderedBy" type="Int64" />
<one-to-many class="DataLayer.Entities.OrderDetails, PCSBAL" />
</map>
</class>

The OrdersDetails Class
<class name="OrderDetails" table="OrderDetails">
<composite-id unsaved-value ="any">
<key-property name="OrderId" column="OrderId" type="Int64" />
<key-property name="OrderedBy" column="OrderedBy" type="Int64" />
</composite-id>
<property column="OrderedOn" type="DateTime" name="OrderedOn" not-null="true" />
</class>

I want that when I retrieve a list of Orders the list is sorted on the count of the Details collection (map) from the Order Class.

The HQL that I build is as below

from DataLayer.Entities.Orders Orders Where Orders.Id=@id order by count(Orders.Details) asc

Before translation to SQL it gives me the following error 'Incorrect query syntax'.

Is it because NHibernate does not allow you to sort in the fashion that I want it to or am I missing something?

Platform: .NET 2.0 and Sql Server 2005

Appreciate your help....


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

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.