AW: AW: AW: AW: [Objectbridge-developers] Q: How to setup the dat abas e?
Brought to you by:
thma
From: Mahler T. <tho...@it...> - 2001-08-08 14:55:15
|
> -----Urspr=FCngliche Nachricht----- > Von: Ivan Toshkov [mailto:to...@cr...] > Gesendet: Mittwoch, 8. August 2001 16:33 > An: Mahler Thomas > Betreff: Re: AW: AW: AW: [Objectbridge-developers] Q: How to setup = the > databas e? >=20 >=20 > Hi again, >=20 > I couldn't find an example of using OJB with an hierarchy of classes. > The only exception is test.ojb.broker.Article and > test.ojb.broker.BookArticle, but the latter does not add any=20 > new fields, > so it's not exactly what I'm looking for. >=20 It does! BookArticle has two additional attributes: /** books author*/ private String author; /** ISBN No of Book*/ private String isbn; (VisualAge does not keep all attributes at the top of a class = definition. I guess that's why you did not find those attributes.) There is also the class CdArticle that does not extend Article but implements the interface Article and introduces also two more = attributes than Article. > To be more specific, let's say we have the following classes: >=20 > abstract class A > { > int num; > } >=20 > class B extends A > { > String name; > } >=20 > class C extends A > { > int count; > } >=20 > The theory says, there are generally 3 representations: >=20 > 1. Store the whole hierarchy in one table: >=20 > table A: > +-----+-----+------+-------+------+ > | oid | num | name | count | type | > +-----+-----+------+-------+------+ >=20 supported by OJB. In the ClassDescriptor of each class you just have to declare that it maps to table A. > 2. Store each concrete class in separate table: >=20 > table B: > +-----+-----+------+ > | oid | num | name | > +-----+-----+------+ >=20 > table C: > +-----+-----+-------+ > | oid | num | count | > +-----+-----+-------+ >=20 supported by OJB. In the ClassDescriptor for class B you have to declare that it maps to = table B (same for Class C and table C). > 3. Store each class in a separate table: >=20 > table A: > +-----+-----+ > | oid | num | > +-----+-----+ >=20 > table B: > +-----+------+ > | oid | name | > +-----+------+ >=20 > table C: > +-----+-------+ > | oid | count | > +-----+-------+ >=20 not directly supported. Could be relaized via a foreign key relation. HTH, Thomas=20 > Which of these are currently supported by OJB and how do the XML > description looks like? >=20 > Best regards, > Ivan >=20 |