-->
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: ICriteria.AddOrder for a linked class
PostPosted: Sun Aug 28, 2005 12:17 am 
Newbie

Joined: Sun Aug 28, 2005 12:00 am
Posts: 2
I have two classes ProjectData and MasterProjectData

Code:
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.0">
   <class name="ProjectData" table="project">
         <key column="projectId" />
         <many-to-one name="IMasterProject" class="CCAdminData.MasterProjectData, CCAdminData" column="masterGuid" />
   </class>
</hibernate-mapping>


Code:
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.0">
   <class name="MasterProjectData" table="MasterProjects">
      <id name="Guid" type="System.Guid" column="guid" unsaved-value="00000000-0000-0000-0000-000000000000">
         <generator class="guid" />
      </id>
      <property name="Name"/>
      <bag name="Projects" inverse="true">
         <key column="masterGuid" />
         <one-to-many class="CCAdminData.ProjectData, CCAdminData" />
      </bag>
   </class>
</hibernate-mapping>



I would like to use a Criteria to search for ProjectsData(s) but i would like to order by MasterProjectData.Name
So my createCriteria is
ICriteria projectCriteria = Db.Session.CreateCriteria(typeof(ProjectData));

To add the order i have tried
Code:
-projectCriteria.AddOrder(Order.Desc("IMasterProject.Name"));
-projectCriteria.AddOrder(Order.Desc("ProjectData.IMasterProject.Name"));      
-projectCriteria.AddOrder(Order.Desc("$this.IMasterProject.Name"));


which all give a NullReferenceException on line 1544 of normalizedentitypersister

Does anyone know how to do this?
The reason i want to use a criteria instead of just writing a query is that i would like to use the SetFirstResult and SetMaxResults of the criteria.

Neither of which works


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.