Hi, I'm trying to get inheritance working with OJB. I want to use the most
complex (but also most versatile) method, multiple joined tables. Here are
my classes:

-----
/**
* @ojb.class table="bit_Person"
*/
public class Person
{
    /**
    * @ojb.field name="id"
    * primarykey="true"
    * jdbc-type="INTEGER"
    * length="11"
    * autoincrement="ojb"
    */
    protected int id;

    /**
    *  @ojb.field
    *  length="64"
    */
    protected String lastName;

    // Removed code for brevity
}


/**
* @ojb.class table="bit_Candidate"
* include-inherited="false"
*/
public class Candidate extends Person
{

 /**
     * @ojb.reference class-ref="nl.bergland.codamo.Person"
     * name="super"
     * foreignkey="id"
     * auto-retrieve="true"
     * auto-update="true"
     * auto-delete="true"
  */

    /**
    * @ojb.field name="id"
    * primarykey="true"
    * jdbc-type="INTEGER"
    * length="11"
    * autoincrement="ojb"
    */
    protected int id;

    /**
    *  @ojb.field
    */
    protected Date availableFrom;

    // Removed code for brevity
}
-----

The classes have all the ususal getters and setters, but I removed that code
here to keep it simple. I want person to map to a table bit_person with an
id and a lastname field. Candidate IS A Person, so it should save it's data
to bit_person.id and bit_person.lastName, however, it should also save the
availableFrom field to bit_candidate.availableFrom and set bit_candidate.id
to be the same as bit_person.id.

This should be possible, but I can't get it to work using OjbDoclet. Can
anyone point out the mistake I am probably making? At the moment, when I
save a Candidate, bit_person is not touched at all.
Here is my repository_user.xml, but remember, that's generated by OjbDoclet.

-----
<!-- file containing the repository descriptions for user-defined types -->
<!-- Generated by the xdoclet-ojb module -->

<class-descriptor
    class="nl.bergland.codamo.Candidate"
    table="bit_Candidate"
>
    <field-descriptor
        name="id"
        column="id"
        jdbc-type="INTEGER"
        primarykey="true"
        autoincrement="true"
        length="11"
    >
    </field-descriptor>
    <field-descriptor
        name="availableFrom"
        column="availableFrom"
        jdbc-type="DATE"
    >
    </field-descriptor>
</class-descriptor>
<class-descriptor
    class="nl.bergland.codamo.Person"
    table="bit_Person"
>
    <extent-class class-ref="nl.bergland.codamo.Candidate"/>
    <field-descriptor
        name="id"
        column="id"
        jdbc-type="INTEGER"
        primarykey="true"
        autoincrement="true"
        length="11"
    >
    </field-descriptor>
    <field-descriptor
        name="lastName"
        column="lastName"
        jdbc-type="VARCHAR"
        length="64"
    >
    </field-descriptor>
</class-descriptor>
-----

Thanks in advance for any help,
-Stijn



---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to