Eugeny Jakover <[EMAIL PROTECTED]> 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: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]