db-torque-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Travis McCauley <tw...@virginia.edu>
Subject Inheritance - restricting access to irrelevant columns
Date Thu, 27 Feb 2003 01:36:18 GMT
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>

Mime
View raw message