-->
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.  [ 4 posts ] 
Author Message
 Post subject: specify order-by column in a child table
PostPosted: Fri Apr 08, 2011 2:12 pm 
Newbie

Joined: Fri Mar 18, 2011 6:20 pm
Posts: 4
I am trying to perform a database sort by using "order-by" option within a many-to-many relationship. The order-by option however requires the name of a column within the link table and I need to sort on a column that is a child of the link table. For example the following designates the sort order to be done on categories.name however I receive the message "column not found" because it is trying to find it in the HEADINGCATEGORY table.

<set name="categories" table="HEADINGCATEGORY" cascade="none" order-by="categories.name asc" lazy="false" >
<key column="HEADING_ID" />
<many-to-many column="category_id" class="Category" />
</set>

Any thoughts would be appreciated.


Top
 Profile  
 
 Post subject: Re: specify order-by column in a child table
PostPosted: Mon Apr 11, 2011 10:37 pm 
Newbie

Joined: Mon Apr 11, 2011 4:19 am
Posts: 11
Hi,

Have you resolved this problem ?

I have used order-by attribute and I used to give the native SQL column name in the order-by attribute. I am not sure, whether there is a support if we give the hibernate property name. However I never have tried so.

I guess, you are specifying the property name for order-by attribute whereas the error message is 'Column not found' which looks to me like, the order-by attribute looks for a native sql column name.

If it looks for the hibernate property, the error message would be something like 'Could not resolve property', correct me if I am wrong.

Thanks,
Senthilkumar Arumugam


Top
 Profile  
 
 Post subject: Re: specify order-by column in a child table
PostPosted: Tue Apr 12, 2011 5:06 am 
Regular
Regular

Joined: Fri Jan 28, 2011 11:44 am
Posts: 117
Hi,

Senthilkumar is right. Take a look at this doc:

http://docs.jboss.org/hibernate/core/3. ... ons-sorted

Quote:
The value of the order-by attribute is an SQL ordering, not an HQL ordering.


Top
 Profile  
 
 Post subject: Re: specify order-by column in a child table
PostPosted: Tue Apr 12, 2011 10:41 am 
Newbie

Joined: Fri Mar 18, 2011 6:20 pm
Posts: 4
thanks for the response!

The problem is that it is a many-to-many relationship and a connecting table exists. The Group-by clause has access to this connecting table and not to the table that I want to sort on. The connecting table consists of two columns, a key to each of the tables we are connecting. The field we want to sort on is in the table we are connecting to. For example we have access to many-to-many connecting table "headingcategory". This table contains a key to heading table and a key to category table. I want to sort on column "name" in the category table. There would not be problem if we wanted to sort on a column in "headingcategory" table however we want to sort on a column in the category table. How can hibernate obtain access to the column name in the category table?


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 4 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.