[prev in list] [next in list] [prev in thread] [next in thread]
List: ojb-user
Subject: RE: Collection creation and sorting
From: "Gelhar, Wallace Joseph" <GELHARWJ () uwec ! edu>
Date: 2004-04-30 13:29:48
Message-ID: FEBBF51AFF7B8B4B8A2F32F6E63092AEF8425D () COKE ! uwec ! edu
[Download RAW message or body]
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
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic