-->
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: order by on composite key
PostPosted: Mon Nov 20, 2006 2:20 am 
Newbie

Joined: Mon Nov 20, 2006 2:09 am
Posts: 1
hey guys!
Can anyone help me with using composite key in hibernate. i have a composite key in my hbm, code as follows
<class name="AnswerSet" table="ANSWER_SET_MEGA_TABLE" >
<composite-id name="answerPK"
class="com.hp.ckmds.dao.hibernate.AnswerPK" >

<key-property name="UniqueId" column="UNIQUE_IDENTIFIER" type="string" />
<key-property name="CodifiedValue" column="CODIFIED_VALUE" type="string"/>

</composite-id>

Now in my code using HQL i want to sort the records using order by and that too on the composite key. how can i do that?

Thanks,


Top
 Profile  
 
 Post subject:
PostPosted: Mon Nov 20, 2006 2:47 am 
Beginner
Beginner

Joined: Mon Nov 22, 2004 11:21 am
Posts: 42
You have to use the name of the composite key or "id" as qualifier for the PK columns, e.g.:
Code:
from AnswerSet
order by answerPK.UniqueId, answerPK.CodifiedValue

or:
Code:
from AnswerSet a
order by a.answerPK.UniqueId, a.answerPK.CodifiedValue

or:
Code:
from AnswerSet a
order by a.id.UniqueId, a.id.CodifiedValue

Regards,
Georg

_________________
Real programmers confuse Halloween and Christmas because OCT 31 = DEC 25


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.