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.  [ 1 post ] 
Author Message
 Post subject: Order By Composite Foreign Keys
PostPosted: Thu Nov 06, 2003 6:16 am 
Newbie

Joined: Thu Nov 06, 2003 5:58 am
Posts: 1
Location: Portugal
Hello 8),

I currently have the need to order a query by a specific field in a composite foreign key (ordering by the foreign key itself would be ok),

the foreign key mapping is as follows:
Code:
<many-to-one
    name="conta"
    class="com.whateversoft.conta.business.entities.ContaVO"
    cascade="none"
    outer-join="false"
    update="true"
    insert="true"
    not-null="false">

    <column name="CodConta" not-null="false"/>
    <column name="CodPlano" not-null="false"/>
</many-to-one>


A Criteria is being used to filter the results and if it's added the following line :
Code:
    criteria.addOrder (Order.asc ("conta"));


I get an error saying that ordering by composite values is not allowed.

I can't acess the columns by themselves; If I add the following order:
Code:
    criteria.addOrder (Order.asc ("conta.contaId.codigo"));


Being contaId ContaVO's property name of class ContaId (containing the composite key values), and codigo being ContaId's property name of type String and mapped to the first part of the composite key of table conta.

The question is... is it possible to order a table by a composite foreign key? if so, how? if not; is it possible to order a table by a part of a composite foreign key? if so, how?

thanks :)
v.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

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.