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 Will Holcomb <wi...@himinbi.org> on 2003/04/01 01:12:30 UTC

use a torque generated class as a base class

I have a project with several tables (~30) and I currently have them
broken up into subprojects. I would like to specify some tables that join
between projects, but am having some trouble doing so.

One example is there is a project that is a discussion board and another 
that is a basic content management system. Every major thing in the 
content management system has a discussion conference associate with it, 
so I the joining project looks like:

<table name="artifact" javaName="OPSArtifact" alias="Artifact"
 baseClass="org.himinbi.artifacts.om.Artifact"
 basePeer="org.himinbi.artifacts.om.ArtifactPeer">
  <column name="id" required="true" primaryKey="true" type="INTEGER" />
</table>

<table name="conference" javaName="OPSConference" alias="Conference"
 baseClass="org.himinbi.directory.om.Conference"
 basePeer="org.himinbi.directory.om.ConferencePeer">
  <column name="id" required="true" primaryKey="true" type="INTEGER" />
</table>

<table name="artifact_conference" description="Conference for an artifact">
  <column name="id" required="true" primaryKey="true" type="INTEGER"/>
  <column name="artifact_id" required="true" type="INTEGER"/>
  <column name="conference_id" required="true" type="INTEGER"/>

  <foreign-key foreignTable="artifact" onDelete="cascade" onUpdate="cascade">
    <reference local="artifact_id" foreign="id"/>
  </foreign-key>
  <foreign-key foreignTable="conference" onDelete="cascade" onUpdate="cascade">
    <reference local="conference_id" foreign="id"/>
  </foreign-key>
</table>

Ideally it would be cool if I didn't have the wrapper classes at all and 
if I could somehow say "give me the conference for an artifact" without 
having to go through the intermediary. I'm assuming that I can't do that.

Even this doesn't work though because the OPSConference class uses the
ConferencePeer's doSelect (which returns a Conference) and then tries to
cast it to an OPSConference and that fails. I am currently using the
classes to get the id's and then looking up the Conference using
ConferencePeer.retrieveByPK.

I read the inheritance guide, but the table part of the schema is just an 
ellipsis...

Is it possible for torque classes to inherit from each other across 
schemas? If so, what am I missing?

Will Holcomb