Each Class in a separate Table

This model uses different tables for the super- and the subclasses. The model is called "Thin Inheritance Model", the JDO 2.0 specification also calls it "new-table" model.

The following diagram shows a sample for the relationships between classes and tables in this case:

Figure: New table model

images/userguide_en/inheritance_thin.gif

All subclasses are defined in the inheritance descriptor in the JDO file. The inheritance provider determines the mapping between the type field and the Java type. The default intelliBO inheritance provider uses full qualified class names to associate each database record to an Java object.

<?xml version="1.0" encoding="UTF-8"?>
<jdo xmlns="http://java.sun.com/xml/ns/jdo/jdo" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
     xsi:schemaLocation="http://java.sun.com/xml/ns/jdo/jdo http://java.sun.com/xml/ns/jdo/jdo_2_0.xsd">

<package name="com.signsoft.ibo.sample">
  <class name="Person">
    <extension vendor-name="ssibo" key="jdbc">
    <extension vendor-name="ssibo" key="table-name" value=" TPERSON" />
    
    <!-- inheritance descriptor -->
      <extension vendor-name="ssibo" key="inheritance">
        <extension vendor-name="ssibo" key="field-name" value="FCLASSTYPE" />
        <extension vendor-name="ssibo" key="subclass"
          value="com.signsoft.ibo.sample.Customer" />
        <extension vendor-name="ssibo" key="subclass"
          value="com.signsoft.ibo.sample.Supplier" />
      </extension>
    </extension>
...
It is not necessary to specify the subclasses for a given class. If you do it, you may achieve some optimizations, and you will avoid having to explicitly register the classes in your application code. This especially applies if you do complex queries where the full inheritance hierarchy has to be known by the Signsoft intelliBO system. Such queries include e.g. class hierarchies using Flat Redundant Inheritance model, and querying for base classes, or using the Flat inheritance model and querying for other classes than the base class.

Even if it is not mandatory, we strongly recommend to specify an inheritance provider if you want to use inheritance. If you do not do this, you may not be able to query the data store for a class and find all objects which belongs to this class or a subclass thereof. This especially applies if you query for abstract base classes.

If the inheritance model consists of more than 2 hierarchy levels, the inheritance provider and all sub classes have to be registered at the highest level.

All derived classes must set the attribute persistence-capable-superclass to indicate their super class.

<jdo>
  <package name="com.test">
    <class name="Customer" identity-type="application"
      objectid-class="com.test.PersonKey"
      persistence-capable-superclass="com.test.Person">

      <field name="creditLimit" default-fetch-group="true" />
    </class>
  </package>
</jdo>
In this example class Customer extends class Person and inherits all of the Person's persistent fields. The ObjectId is also inherited from class Person and is not declared again:
public class Customer extends Person
{
  private double creditLimit;
  . . .
When using such inheritance relations please ensure that the primary keys in the tables of superclass and subclass are equal. Signsoft intelliBO will try to optimize your SQL statements according to those inheritance relationships.

When working with the class Person , there is no special action or care needed when using inheritance. Just use your objects as you would use non-persistent objects in Java.