From dan@iacmail.wustl.edu Thu Apr 17 20:07:46 2003 Return-Path: Mailing-List: contact torque-user-help@db.apache.org; run by ezmlm Delivered-To: mailing list torque-user@db.apache.org Received: (qmail 59060 invoked from network); 17 Apr 2003 20:07:46 -0000 Received: from iac3.wustl.edu (128.252.27.213) by daedalus.apache.org with SMTP; 17 Apr 2003 20:07:46 -0000 Received: from snapper (snapper.psychology.wustl.edu [128.252.57.222]) by iac3.wustl.edu (8.8.8p2+Sun/8.8.8) with ESMTP id PAA25845 for ; Thu, 17 Apr 2003 15:07:50 -0500 (CDT) From: "Dan Marcus" To: Subject: overriding default inheritance Date: Thu, 17 Apr 2003 15:07:43 -0500 Message-ID: <002901c3051d$04954df0$de39fc80@snapper> MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="----=_NextPart_000_002A_01C304F3.1BBF45F0" X-Priority: 3 (Normal) X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook, Build 10.0.3416 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1106 Importance: Normal X-Spam-Rating: daedalus.apache.org 1.6.2 0/1000/N ------=_NextPart_000_002A_01C304F3.1BBF45F0 Content-Type: text/plain; charset="US-ASCII" Content-Transfer-Encoding: 7bit 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 ------=_NextPart_000_002A_01C304F3.1BBF45F0--