-->
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: How to define order-by column in a many-to-many relationship
PostPosted: Sun Nov 13, 2005 4:50 pm 
Newbie

Joined: Sun Nov 13, 2005 12:31 pm
Posts: 3
I have:

<set name="itens" cascade="all" table='"SIM_PROJECTITEM"'>
<key column="fkproject"/>
<many-to-many column="fktreenode" class="br.com.simageWeb.models.TreeNode"/>
</set>

in my project mapping file and I want to recover my itens order by its names. If I add

order-by="name asc" in the <set> I got a error that says

"Caused by: org.postgresql.util.PSQLException: ERROR: column itens0_.name does not exist".

I think that the Hibernate is searching for name in the intermediate table. So, what is wrong?


Top
 Profile  
 
 Post subject:
PostPosted: Tue Dec 20, 2005 10:24 am 
Newbie

Joined: Tue Dec 16, 2003 12:02 pm
Posts: 14
Location: Geneva, Switzerland
AFAIK, you cannot define an order-by in your example.
However you could use HQL to order your collection in the application using something like:

Code:
List myOrderedCollection = session.createFilter(myObject.getItems(), "order by this.name")
                                             .list();


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.