Hallo,

I'm trying to store an object which inherits some attributes from a
superclass, but values are only be inserted in the subclass table an
nothing is inserted in the superclass table.

Objectmodel:
Class BusinessPartner()
 Integer bpid;
 String attribute

Class Individual extends BusinessPartner()
 String oneMoreAttribute;

To get it a little bit more complicated I use the JDO plugin my
JDO-Files look as follows:

==> Individual.jdo
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE jdo PUBLIC "-//Sun Microsystems, Inc.//DTD Java Data 
Objects Metadata 1.0//EN"
"http://java.sun.com/dtd/jdo_1_0.dtd";>
<jdo>
  <package name="demo.myshop.model.ojb">
    <class name="Individual"
persistence-capable-superclass="demo.myshop.model.ojb.BusinessPartner">
        <field name="fk_bpid" persistence-modifier="persistent"></field>
        <field name="gender" persistence-modifier="persistent"></field>
    </class>
  </package>
</jdo>

==> BusinessPartner.jdo
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE jdo PUBLIC "-//Sun Microsystems, Inc.//DTD Java Data 
Objects Metadata 1.0//EN"
"http://java.sun.com/dtd/jdo_1_0.dtd";>
<jdo>
  <package name="demo.myshop.model.ojb">
    <class name="BusinessPartner" identity-type="datastore">
        <field name="Bpid" persistence-modifier="persistent"></field>
        <field name="Adress" persistence-modifier="persistent"></field>
        <field name="Name" persistence-modifier="persistent"></field>
    </class>
  </package>
</jdo>

The Repository.xml looks as follows:

    <class-descriptor
        class="demo.myshop.model.ojb.BusinessPartner"
        table="OJB_BUSINESSPARTNER">
        <field-descriptor
                name="Bpid"
                column="BPID"
                jdbc-type="INTEGER"
                primarykey="true"
                autoincrement="true"/>
        <field-descriptor
                name="Adress"
                column="ADRESS"
                jdbc-type="VARCHAR"/>
        <field-descriptor
                name="Name"
                column="NAME"
                jdbc-type="VARCHAR"/>
    </class-descriptor>
    
   <class-descriptor
        class="demo.myshop.model.ojb.Individual"
        table="OJB_INDIVIDUAL"> 
   <field-descriptor
                name="fk_bpid"
                column="FK_BPID"
                jdbc-type="INTEGER"
                primarykey="true"
                autoincrement="true"/>
        <field-descriptor
                name="gender"
                column="GENDER"
                jdbc-type="VARCHAR"/>
        <reference-descriptor name="super"
             class-ref="demo.myshop.model.ojb.BusinessPartner">
                <foreignkey field-ref="fk_bpid" />
        </reference-descriptor>
    </class-descriptor>

The source code:
        //Individual Testdata
        Individual ind0 = new Individual();
        ind0.setAdress("Adress IND0");
        ind0.setName("Name IND0");
        ind0.setGender("male");
        t.begin();
        pm.makePersistent(ind0);
        t.commit();

So the problem was that there is only an entry in the OJB_INDIVIDUAL
table an none in the OJB_BUSINESSPARTNER table.

I hope someone can help me !

Thanks,
Stephan

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

Reply via email to