-->
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: Is it possible to add Order on a child object's column?
PostPosted: Mon Mar 27, 2006 5:28 pm 
Newbie

Joined: Mon Mar 27, 2006 5:11 pm
Posts: 1
Hil All:

I am using:

NHibernate version: 1.0.1
MS SqlServer 2000

I am trying to create a query using CreateQuery method. And in that I want order the query objects to two level depth. For example:

IList records = session.CreateCriteria(typeof(Procurement))
.AddOrder(entityOrder)
.List();

and "entityOrder" defined as below:
Order entityOrder = Order.Desc("Department.DptEntity");

Please note that "Department" object represents a column in the "Procurement" table and "DptEntity" represents a column in the "Department" table.

This query generates exception saying "Use the NEW keyword to create an object". Through the debugger I checked that all my values are good including "entityOrder" (at least it does not generate exception on that statement (for "entityOrder" assignment).

Can anybody give me a clue? If two multi-depth is not allowed (as in ("Department.DptEntity"), how can I change it to reach my objective? I will appreciate the help.

Thank you.


Top
 Profile  
 
 Post subject:
PostPosted: Mon Mar 27, 2006 6:31 pm 
Expert
Expert

Joined: Mon Jan 09, 2006 5:01 pm
Posts: 311
Location: Sacramento, CA
As far as I know in a M-to-M it is only possible to "order-by" columns in the intermediate table. You'd have to "sort" on the java side with a comparator to achieve an ordered list from otherEntity.col.

_________________
-JT

If you find my replies helpful, please rate by clicking 'Y' on them. I appreciate it.


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.