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 Joerg Lensing <in...@softcon-lensing.de> on 2003/05/30 10:38:12 UTC

Mapping two (or more) classes to one table

hi,
i want to map two classes to the same table.
-PartentA
    -ChildA
    -ChildB

ParentA is abstract. ChildA and ChildB must be retrieved by using
the same atttributes (inherited from ParentA).

I tried it, but by using the unique-key as
 >>>crit.addEqualTo("id", "515522");
the wrong class is returned.

is there anything special to do in the mapping?

joerg


Re: Mapping two (or more) classes to one table

Posted by Alexander Prozor <ap...@isd.dp.ua>.
Hello Joerg,
in the turorial3.html file ( doc ).
see the section mapping inheritance hierarchy to the same table.
as far as I understand it's required additional column in the table
<field-descriptor
         name="ojbConcreteClass"
         column="CLASS_NAME"
         jdbc-type="VARCHAR"
/>

or you have to derive a Class from org.apache.ojb.broker.accesslayer.RowReaderDefaultImpl
and overwrite the method selectClassDescriptor to implement your specific type selection
mechanism

hope to help you.

JL> hi,
JL> i want to map two classes to the same table.
JL> -PartentA
JL>     -ChildA
JL>     -ChildB

JL> ParentA is abstract. ChildA and ChildB must be retrieved by using
JL> the same atttributes (inherited from ParentA).

JL> I tried it, but by using the unique-key as
JL>  >>>crit.addEqualTo("id", "515522");
JL> the wrong class is returned.

JL> is there anything special to do in the mapping?

JL> joerg


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



-- 
Best regards,
 Alexander                            mailto:apro@isd.dp.ua