You are viewing a plain text version of this content. The canonical link for it is here.
Posted to torque-user@db.apache.org by Travis McCauley <tw...@virginia.edu> on 2003/02/27 02:36:18 UTC

Inheritance - restricting access to irrelevant columns

Hi,

Is there any way for Torque to understand the relationship between 
specific columns and specific subclasses?

I studied the generated code from the schema below (simplified). It 
builds the class hierarchy correctly but the subclasses seem to be 
different in name only. Is there any way to specify in the schema 
which columns are relevant to which subclasses?

In this example, each of the columns in the last block should be 
unique to one the three subclasses: Person, Project, Organization. 
The generated code would let a Person object have an organization 
name. If Torque can't specify these relationships, how have people 
been restricting access to irrelevant attributes? Do you just 
override the accessors and throw exceptions in the body?

Thanks for any ideas,

Travis McCauley
University of Virginia

<table name="RosterMember">

<!--metadata-->
<column name="id" primaryKey="true" required="true" type="INTEGER"/>
<column name="created_by" required="true" type="INTEGER"/>
<column name="modified_by" required="true" type="INTEGER"/>
<column name="created_on" required="true" type="TIMESTAMP"/>
<column name="modified_on" required="true" type="TIMESTAMP"/>
<column name="deleted" required="true" size="5" type="CHAR"/>

<!--inheritance key-->
<column name="member_class" inheritance="single" type="VARCHAR" size="24">
<inheritance key="person" class="Person" extends="RosterMember"/>
<inheritance key="project" class="Project" extends="RosterMember"/>
<inheritance key="organization" class="Organization" extends="RosterMember"/>
</column>

<!--columns unique to subclasses-->
<column name="person_name" type="LONGVARCHAR"/>
<column name="project_name" type="LONGVARCHAR"/>
<column name="organization_name" type="LONGVARCHAR"/>

</table>