db-torque-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Thomas Fischer <fisc...@seitenbau.net>
Subject RE: Inheritance and additional attributes
Date Fri, 26 May 2006 09:48:51 GMT
Hi,

It is not possible to define additional attributes in the subclasses, nor
is it possible to use another table for this. You must declare all members
in the one table where all the class hierarchy are saved to. What you can
do is to declare the "additional" members als protected, and override the
getters and setters with public methods in the subclass where you want to
access them.

           Thomas

Florian Hopf <hopf@synyx.de> schrieb am 24.05.2006 10:38:41:

> Hi *,
> I'm trying to get inheritance working and can't find a solution in the
> archives and the inheritance guide.
> What I want to achieve is something like this:
> I have an abstract class Element which defines a lot of attributes. This
> class is extended by a few other concrete classes that define additional
> attributes. So I define the abstract class like this:
>
>   <table name="element" abstract="false" description="the abstract
> document element">
>     <column
>         name="id"
>         required="true"
>         primaryKey="true"
>         type="INTEGER"
>         description="Id"/>
>     <column
>         name="document_id"
>         required="true"
>         type="INTEGER"
>         description="reference to the corresponding document"/>
>
> [snip more attributes]
>
>     <column
>         name="class_type"
>         inheritance="single"
>         type="VARCHAR"
>         size="10">
>             <inheritance key="text" class="TextElement"/>
>     </column>
>     <foreign-key foreignTable="document" onDelete="cascade">
>       <reference local="document_id" foreign="id"/>
>     </foreign-key>
>   </table>
>
> And the concrete subclass like this:
>
> <table name="text_element" abstract="false" description="element to
> represent text content">
>     <column
>         name="content"
>         required="true"
>         type="VARCHAR"
>         description="the text content"
>     />
> </table>
>
> What happens is, as far as I can see, the generator generates classes
> for TextElement/TextElementPeer and afterwards overwrites TextElement
> with one that extends Element without the additional attribute. Is it
> possible to make inheritance with additional attributes work? Do I have
> to declare the attributes in Element and tag them as belonging to
> TextElement somehow?
>
> Any hint is appreciated,
> kind regards
> Florian
>
> --
> /**
>  * Florian Hopf
>  * Synyx GmbH & Co. KG
>  * phone  +49(0)721 9118303
>  * eMail  hopf@synyx.de
>  * www    http://www.synyx.de
>  * irc    irc.synyx.de
>  */
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: torque-user-unsubscribe@db.apache.org
> For additional commands, e-mail: torque-user-help@db.apache.org
>


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


Mime
View raw message