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 a field NOT in the Primary key?
PostPosted: Tue Nov 27, 2007 6:05 pm 
Newbie

Joined: Thu Nov 01, 2007 1:06 pm
Posts: 12
What I'm really trying to do is specify an "ORDER-BY" clause in the set one-to-many description that is ONLY in the related class.

For example,

Assume I have these two mappings:

Code:
<class name="Table1" table="TABLE_1">
  <id name="pk" column="T1_PK" type="string"/>
  <!-- none of the other fields matter -->

  <set name="table2s" inverse="true" order-by="??????">
    <key column="T2_FK"/>
   <one-to-many class="Table2"/>
  </set>
</class>


<class name="Table2" table="TABLE_2">
  <id name="pk" column="T2_PK" type="string"/>
  <property name="sequence" column="SQNC" type="string"/>
  <property name="description" column="DESC" type="string"/>
</class>


What I really want is for all my "Table2" objects retrieved in that set to be ordered by the "SQNC" column.

However, it seems like my only choice for "ORDER-BY" in this case is "T2_PK" and I DON'T want it ordered by it!


Is my only solution to use HQL? I'd much prefer to be able to use object loading...

Thoughts?

ps. if my mapping files don't explain my dilema here is a simple table printout that expresses my desire:

Code:
TABLE_1        TABLE_2
----------   |  --------------
T1_PK        |  T2_PK
T2_FK        |  T2_COL2   #I WANT TO ORDER BY THIS COLUMN!
T1_COL3      |  T2_COL3
T1_COL4      |


Top
 Profile  
 
 Post subject:
PostPosted: Wed Nov 28, 2007 9:54 pm 
Newbie

Joined: Thu Nov 01, 2007 1:06 pm
Posts: 12
so, by the lack of response to this I'm assuming it is impossible to specify mulitple "order-by" attributes for the Collection mapping?

:(


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.