db-torque-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Dan Marcus" <...@iacmail.wustl.edu>
Subject overriding default inheritance
Date Thu, 17 Apr 2003 20:07:43 GMT
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

 

 


Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message