Re: Collection creation and sorting

2004-05-01 Thread Tino Schöllhorn
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]


questions: api, old objects, list to column mapping

2004-05-01 Thread Robert
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: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Cannot create table OJB_DMAP_ENTRIES on DB2

2004-05-01 Thread Sean Kirby
Hi all,

I'm using OJB 1.0RC6 in conjunction with DB2 and when i try to run the 
junit target in the build.xml file i get the following error:

[torque-sql-exec] Failed to execute: CREATE TABLE OJB_DMAP_ENTRIES ( ID 
INTEGER NOT NULL, DMAP_ID INTEGER NOT NULL, KEY_OID VARCHAR(250) FOR BIT 
DATA VARCHAR(n) FOR BIT DATA, VALUE_OID VARCHAR(250) FOR BIT DATA 
VARCHAR(n) FOR BIT DATA )
[torque-sql-exec] COM.ibm.db2.jdbc.DB2Exception: [IBM][CLI 
Driver][DB2/LINUX] SQL0104N  An unexpected token VARCHAR was found 
following AR(250) FOR BIT DATA.  Expected tokens may include: 
REFERENCES.  SQLSTATE=42601

Poking around in the ojbcore-schema.sql file, under the 
OJB_DMAP_ENTRIES section i see:

CREATE TABLE OJB_DMAP_ENTRIES
(
ID INTEGER NOT NULL,
DMAP_ID INTEGER NOT NULL,
KEY_OID VARCHAR(250) FOR BIT DATA VARCHAR(n) FOR BIT DATA,
VALUE_OID VARCHAR(250) FOR BIT DATA VARCHAR(n) FOR BIT DATA
);
Changing this SQL to:

CREATE TABLE OJB_DMAP_ENTRIES
(
ID INTEGER NOT NULL,
DMAP_ID INTEGER NOT NULL,
KEY_OID VARCHAR(250) FOR BIT DATA,
VALUE_OID VARCHAR(250) FOR BIT DATA
);
eliminates these errors.

So finally, my question is:  is this a torque or and ojb problem and is 
there a work-around that doesn't require manual edits?

Thanks and apologies if this issue is already known,

Sean Kirby

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]