Hi Tino, Did you try something like this?
<class-descriptor class="Company" table="tblCompany" > ... <collection-descriptor name="companyTeams" element-class-ref="CompanyTeam"> <orderby name="pos" /> <orderby name="c.name" /> <inverse-foreignkey field-ref="CompanyID"/> </collection-descriptor> ... </class-descriptor> Wally -----Original Message----- From: news [mailto:[EMAIL PROTECTED] On Behalf Of Tino Schöllhorn Sent: Saturday, May 01, 2004 2:21 AM To: [EMAIL PROTECTED] Subject: Re: Collection creation and sorting 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:[EMAIL PROTECTED] On Behalf Of Tino Schöllhorn > Sent: Friday, April 30, 2004 2:41 AM > To: [EMAIL PROTECTED] > 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: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]