You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@turbine.apache.org by Eugeny Jakover <Eu...@novocybersk.ru> on 2001/06/11 12:22:47 UTC
Using Torque for class hierarchy
Hi!
I have a question on using Torque for generating OM classes which I can't
resolve studying the documentation.
Suppose the OM where several classes (say ClassB, ClassC etc.) extend
one base class (say ClassA) which gathers common attributes of these
classes. How can I tell that that particular table in the project
schema file contains the objects of ClassB which extends ClassA and
avoid to manually copy common attributes?
Is it possible with Torque?
P.S. Sorry for my English it isn't my native language
---------------------------------------------------------------------
To unsubscribe, e-mail: turbine-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: turbine-user-help@jakarta.apache.org
Re: Using Torque for class hierarchy
Posted by Eugeny Jakover <Eu...@novocybersk.ru>.
Daniel Rall wrote:
>
> You may be able to leverage the "inheritance" entity. Here's an
> example for several different subclasses of an "Attribute" class:
>
Thanks, Daniel! I'll try it.
---------------------------------------------------------------------
To unsubscribe, e-mail: turbine-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: turbine-user-help@jakarta.apache.org
Re: Using Torque for class hierarchy
Posted by Daniel Rall <dl...@finemaltcoding.com>.
Eugeny Jakover <Eu...@novocybersk.ru> writes:
> Hi!
>
> I have a question on using Torque for generating OM classes which I can't
> resolve studying the documentation.
>
> Suppose the OM where several classes (say ClassB, ClassC etc.) extend
> one base class (say ClassA) which gathers common attributes of these
> classes. How can I tell that that particular table in the project
> schema file contains the objects of ClassB which extends ClassA and
> avoid to manually copy common attributes?
>
> Is it possible with Torque?
>
> P.S. Sorry for my English it isn't my native language
You may be able to leverage the "inheritance" entity. Here's an
example for several different subclasses of an "Attribute" class:
<table name="HELM_ATTRIBUTE" idMethod="autoincrement"
javaName="Attribute">
<column name="ATTRIBUTE_ID" type="INTEGER" required="true"
autoIncrement="true" primaryKey="true"/>
<column name="TYPE_ID" type="INTEGER" required="true"/>
<!-- Possible values: 'Host', 'Domain', 'Project', 'Role' -->
<column name="ENTITY_TYPE" type="VARCHAR" size="64" required="true"
inheritance="single">
<inheritance key="Host" class="HostAttribute" extends="Attribute"/>
<inheritance key="Domain" class="DomainAttribute" extends="Attribute"/>
<inheritance key="Project" class="ProjectAttribute" extends="Attribute"/>
<inheritance key="Role" class="RoleAttribute" extends="Attribute"/>
</column>
<column name="NAME" type="VARCHAR" size="128" required="true"/>
<column name="DEFAULT_VALUE" type="LONGVARCHAR" default=""
required="true"/>
<column name="DESCRIPTION" type="LONGVARCHAR" default=""/>
<foreign-key foreignTable="HELM_ATTRIBUTE_TYPE">
<reference local="TYPE_ID" foreign="ATTRIBUTE_TYPE_ID"/>
</foreign-key>
<unique>
<unique-column name="ENTITY_TYPE"/>
<unique-column name="NAME"/>
</unique>
</table>
If that doesn't work, you can put the code in a helper class and
delegate to that from your OMs.
Daniel
---------------------------------------------------------------------
To unsubscribe, e-mail: turbine-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: turbine-user-help@jakarta.apache.org