db-ojb-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Carsten Spräner_Ext" <CSprae...@provinzial-online.de>
Subject Re: Referencing an abstract class. The next turn...
Date Tue, 12 Oct 2004 11:26:02 GMT

Hi Armin,

yes the problem description is right, but ojb behaves not as you described.
At least in my test case it doesn't. I tried to use the
ojbConcreteClass-Feature together with a superID from Dog to Animal. The
Database contains the following data:

TABLE_ZOO
ID  CLASS_NAME
1   db.Zoo

TABLE_ANIMAL
ID   ZOO_ID  NAME      CLASS_NAME
1    1       Struppi   db.Dog
2    1       Theresa   db.Animal

TABLE_DOG
SUPER_ID  BITES  CLASS_NAME
1         TRUE   db.Dog

Loading object db.Zoo(id=1) results in the following structure:

Zoo
  Object id=1
  Collection animals
= [Dog(id=1,'Struppi',null),Animal(id=2,'Theresa'),Animal(id=1,'Struppi')];

The type is OK for the first two objects but Struppi is contained two
times? Also the attributes of Dog are not retrieved for Struppi. Only the
attributes of Animal are.

The repository is used for this test uses the ojbConcreteClass feature. If
i remove this feature the result is:

Zoo
  Object id=1
  Collection animals
= [Animal(id=1,'Struppi'),Animal(id=2,'Theresa'),Animal(id=1,'Struppi')];

Both times anmilas[0] is the same instance then animals[2]!

If i give the TABLE_DOG a new primary key attribute ID and map this to
Dog.id and make all PKs in the extend of animal unique

TABLE_ANIMAL
ID   ZOO_ID  NAME      CLASS_NAME
1    1       Struppi   db.Dog
3    1       Theresa   db.Animal

TABLE_DOG
ID   SUPER_ID  BITES  CLASS_NAME
2    1         TRUE   db.Dog

than the result is:
Zoo
  Object id=1
  Collection animals
= [Animal(id=1,'Struppi'),Animal(id=2,'Theresa'),Dog(id=1,'Struppi','TRUE')];

This meets the requirements best.

In all test cases the extend db.Dog is registered in db.Animal in the
repository.

Funny....

carsten

P.S.: I can post you a test program if you want.



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


Mime
View raw message