db-torque-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Travis McCauley <tw...@virginia.edu>
Subject Re: Mapping fields to subclasses in XML schema
Date Sun, 02 Mar 2003 02:00:54 GMT
I asked a similar question last Wednesday and also got no replies. 
I've also seen similar questions unanswered in the archives. I don't 
think it's possible to map this in the schema. If it was, either 
someone would say or it would be in the tutorial.

I set up a simple interface to maintain the subclass-to-column 
relationships. If a subclass tries to access an inappropriate field I 
just throw an exception. I also had to override the copy() method to 
allow casting back to the subclass.

Please someone let us know if there is an easier way.

Sincerely,
Travis McCauley
Snowy Virginia




>I don't suppose anyone can enlighten me on the below message? I 
>didn't hear from anyone. Sorry for the spam, I won't ask again. ;)
>
>Gabe
>
>Gabriel Bauman wrote:
>>Hi there. I understand that classes and their subclasses are mapped 
>>onto a single table under Torque. What I don't understand is how to 
>>specify that a field should only be retrieved in a subclass.
>>
>>=====
>>public class SuperClass
>>{
>>    public int FOO;
>>}
>>
>>public class SubClass extends SuperClass
>>{
>>    public int BAR;
>>}
>>=====
>>
>><table name="superclass" javaName="SuperClass">
>>   <column name="FOO" type="int" />
>>   <column name="BAR" type="int" />
>>   <column name="inheritance" inheritance="single" type="CHAR">
>>     <inheritance
>>        class="SubClass"
>>        extends="SuperClass"
>>        key="A"
>>        />
>>   </column>
>></table>
>>
>>=====
>>I want to be sure that field BAR does not exist in instances of 
>>SuperClass, given the fact that they're both mapped on the same 
>>table. How should my XML schema look in this situation? I must be 
>>missing something simple here.
>>
>>Thanks in advance...
>>
>>Gabe
>>
>>
>>---------------------------------------------------------------------
>>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