You are viewing a plain text version of this content. The canonical link for it is here.
Posted to ojb-user@db.apache.org by Tino Schöllhorn <t....@tiscali.de> on 2004/05/01 09:20:32 UTC
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: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
Re: questions: api, old objects, list to column mapping
Posted by Armin Waibel <ar...@apache.org>.
Hi Robert,
Robert wrote:
> Hi,
>
> I have some questions about OJB.
> There are three APIs that you can use: Persistence Broker, ODMG and JDO.
> Do you have to choose one of these APIs to use in your project, or is it
> normal to mix them and use the one that is most convenient at the moment?
>
You have to choose one api, but when using the top-level api's (ODMG,
OTM,JDO)it is possible (or will be in future) to get access to the
underlying PB kernel api.
> What if the database in your application is running for some time and you
> want to change the definition of the class ir change the mapping.
> For example you want to add a Nationality field to a Person class.
> What will happen to the old persistent Person objects? Can you specify a
> default value for the old objects?
>
No, OJB use the "java default values" for fields. But I think in your
example it make sense to set a default value when alter the DB table.
> Is it possible to map a List to a table in such a way that entry 1 to 5
> is mapped to column 1 to 5 in a table?
>
you have to do it by your own, currently there is no such feature.
regards,
Armin
> Thanks for any answers,
> Robert.
>
>
> ---------------------------------------------------------------------
> 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
questions: api, old objects, list to column mapping
Posted by Robert <rv...@xs4all.nl>.
Hi,
I have some questions about OJB.
There are three APIs that you can use: Persistence Broker, ODMG and JDO.
Do you have to choose one of these APIs to use in your project, or is it
normal to mix them and use the one that is most convenient at the moment?
What if the database in your application is running for some time and you
want to change the definition of the class ir change the mapping.
For example you want to add a Nationality field to a Person class.
What will happen to the old persistent Person objects? Can you specify a
default value for the old objects?
Is it possible to map a List to a table in such a way that entry 1 to 5
is mapped to column 1 to 5 in a table?
Thanks for any answers,
Robert.
---------------------------------------------------------------------
To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
For additional commands, e-mail: ojb-user-help@db.apache.org