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 Thomas Dudziak <to...@gmail.com> on 2004/12/30 16:46:17 UTC
Re: Howto handle inheritance with an abstract classes
Nils Liebelt wrote:
>Hi,
>
>I am struggling with a simple extend of an abstract class, trying to use
>multiple joined tables.
>
>I get following MetadataException: Can't create new base class object for
>'za.co.ibn.datasolutions.entities.Contact'
>
>A soon as I remove the abstract modifier everything works.
>
>Here's my Repository:
>
><class-descriptor
> class="za.co.ibn.datasolutions.entities.Contact"
> table="Contact"
>
>
> <field-descriptor
> name="contactID"
> column="contactID"
> jdbc-type="INTEGER"
> primarykey="true"
> autoincrement="true"
> >
> </field-descriptor>
> <field-descriptor
> name="address"
> column="address"
> jdbc-type="VARCHAR"
> length="254"
> >
> </field-descriptor>
></class-descriptor>
><class-descriptor
> class="za.co.ibn.datasolutions.entities.Individual"
> table="Individual"
>
>
> <field-descriptor
> name="contactID"
> column="contactID"
> jdbc-type="INTEGER"
> primarykey="true"
> autoincrement="true"
> >
> </field-descriptor>
> <reference-descriptor
> name="super"
> class-ref="za.co.ibn.datasolutions.entities.Contact"
> auto-retrieve="true"
> auto-update="true"
> auto-delete="true"
> >
> <foreignkey field-ref="contactID"/>
> </reference-descriptor>
></class-descriptor>
>
>It really don't know what else to try. Did everything according to the
>advanced technique tutorial.
>
>
The problem seems to be that for storing/materializing an instance of
Individual, a concrete instance of the type referenced by the
super-reference is needed. But since this class is abstract, no such
object can be built. While this scenario may sound feasible in Java
terms (because the fields of Contact are duplicated in Individual), when
mapped to a reference OJB's behaviour actually makes sense because the
mapping is a 'normal' reference. Only there is no concrete field to
implement the reference on the Java side, but rather an anonymous field
is used by OJB to store the end of the reference (an instance of
Contact) and the values of this object are then used for the Individual
instance.
So, I'd say there is currently no way around making Contact a concrete
class.
Tom
---------------------------------------------------------------------
To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
For additional commands, e-mail: ojb-user-help@db.apache.org