db-ojb-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Tino Schöllhorn <t.schoellh...@tiscali.de>
Subject Re: Collection creation and sorting
Date Sat, 01 May 2004 07:20:32 GMT
Hi Gelhar,

the thing is: I have a decomposed N:M-relationship and the attributes 
after which I want to sort the collection are members of different classes!

Any ideas?
Tino

Gelhar, Wallace Joseph wrote:
> Hi Tino,
> 
> Sure you can do this.  An example:
> 
> <class-descriptor class="BuildingImpl" table="tblPlnBuilding" >
> ...
> <collection-descriptor
>         name="rooms"
>         element-class-ref="RoomImpl">
>         <orderby name="roomNo" sort="ASC" />
>         <orderby name="roomSuffix" sort="DESC" />
>         <inverse-foreignkey field-ref="buildingId"/>
> </collection-descriptor>
> ...
> </class-descriptor>
> 
> Where roomNo and roomSuffix are attributes on the RoomImpl object.
> 
> Wally
> -----Original Message-----
> From: news [mailto:news@sea.gmane.org] On Behalf Of Tino Schöllhorn
> Sent: Friday, April 30, 2004 2:41 AM
> To: ojb-user@db.apache.org
> Subject: Collection creation and sorting
> 
> 
> Hi,
> 
> I have a (probably simple) question about sorting collections:
> 
> I have 3 classes which I successfully mapped to OJB:
> 
> class Company {
>    Collection companyTeams;
> 
>    public Collection getTeams() {
> 	//???
>    }
> }
> 
> class CompanyTeam {
>    Company c;
>    Team t;
>    int pos;
> }
> 
> class Team {
>    String name;
>    Collection companyTeams;
> }
> 
> Now I want to achieve the following: The method getTeams() of class 
> Company should return all Teams of that Company *sorted by 
> CompanyTeam.pos AND Team.name*.
> 
> I know that I could write a quite complicated Comparator which just does 
> that - but I have many other cases where I had to do that. And writing 
> Comparators is not fun and is very error prone.
> 
> Is there a way to tell OJB that it should load the Collections in a such 
> ordered fashion? I know that one can specify several orderby attributes 
> but is it also possible to specify the orderby attributes which are 
> located in different tables?
> 
> Or should I implement a QueryCustomizer?
> 
> In hope for help.
> tino
> 
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
> For additional commands, e-mail: ojb-user-help@db.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
For additional commands, e-mail: ojb-user-help@db.apache.org


Mime
View raw message