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 Dan Marcus <da...@iacmail.wustl.edu> on 2003/04/17 22:07:43 UTC

overriding default inheritance

Hi-

 

My database schema has a number of subtypes that derive from a single
parent.  The subtypes tend to have very different attributes, so the
default method of inheritance used by Torque - mapping all attributes of
all subtypes to a single table - seems like an inefficient solution.
Actually, it seems like an odd solution in any case, but that's another
matter.

 

The Inheritance Guide on the Torque site suggests an alternative
solution that creates separate tables for each subtype.  I'd like to use
this approach but am having some issues implementing a getOMClass
method.  The guide uses the following code from the Scarab project as an
example (I omitted the cache stuff for simplicity):

/**

 * Get the className appropriate for a row in the

 * SCARAB_ISSUE_ATTRIBUTE_VALUE table

 */

public static Class getOMClass(Record record, int offset)

    throws Exception

{

    NumberKey attId = new NumberKey(record.getValue(offset-1 +
2).asString());

    Attribute attribute = Attribute.getInstance(attId);

    String className = attribute.getAttributeType().getJavaClassName();

 

    Class c = null;

    c = Class.forName(className);

    return c;

}

 

This code confuses me, since it resides within the subtype class, yet
goes to some length to find out what subtype it is.  Isn't the
getOMClass method just trying to return a Class instance representing
the subtype class? The code below seems much simpler.  Am I missing
something? 

 

public static Class getOMClass(Record record, int offset)

    throws Exception

{

 

    String className = "org.tigris.scarab.om.AttributeValue";

    Class c = Class.forName(className);

    return c;

}

 

 

Thanks is advance,

Dan Marcus