The example is used for JDO and XML. If you run it you will see that it's working.
Please see:

example/jdo/mapping.xml
example/jdo/create.sql
example/jdo/test.java
example/myapp/Product.java
example/myapp/Computer.java

If you modify that example for your problem you will get:

create table A (
  id     int not null,
  data   varchar(200) not null,
);

create table B (
  id     int not null,
  other  varchar(200) not null
);


  <class name="A" identity="id">
    <map-to table="A"/>
    <field name="id" type="integer">
      <sql name="id" type="integer" />
    </field>
    <field name="data" type="string">
      <sql name="data" type="varchar" />
    </field>
  </class>

  <class name="B" extends="A" identity="id">
    <map-to table="B" xml="computer" />
    <field name="id" type="integer">
      <sql name="id" type="integer" />
    </field>
    <field name="other" type="string">
      <sql name="other" type="varchar"/>
    </field>
  </class>


public class A implements Persistent
{
    private int          _id;
    public int getId() { return _id; }
    public void setId(int id) { _id = id; }

    private String       _data;
    public String getData() { return _data; }
    public void setData(String data) { _data = data; }

    private Database     _db;
    public void jdoPersistent(Database db) { _db = db; }
    public void jdoTransient() { _db = null; }

    public Class jdoLoad(short accessMode)
    {
        // You need to decide with any property 
        // of A if it is a A or a B object e.g.
        if ( _data.indexOf("B") >= 0 ) return B.class;
        return null;
    }

    public void jdoBeforeCreate(Database db) {}
    public void jdoAfterCreate() {}
    public void jdoStore(boolean modified) {}
    public void jdoBeforeRemove() {}
    public void jdoAfterRemove() {}
    public void jdoUpdate() {}
}


public class B extends A
{
    private String  _other;
    public String getOther() { return _other; }
    public void setOther(String other) { _other = other; }
}

I have not setup the example on my database at the moment,
but as far as I understand the example b.id will be set to a.id
if you create a B object.

Ralf


----- Original Message ----- 
From: "Techeira, Vincent X -ND" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Thursday, March 13, 2003 5:48 PM
Subject: Re: [castor-dev] Loading Extended Objects


> The example doesn't use an identity and maps to XML, I have to use an identity since 
> I'm mapping to a database.
> 
> -----Original Message-----
> From: Ralf Joachim [mailto:[EMAIL PROTECTED]
> Sent: Thursday, March 13, 2003 4:27 AM
> To: [EMAIL PROTECTED]
> Subject: Re: [castor-dev] Loading Extended Objects
> 
> 
> Hi,
> 
> did you take a look on castor JDO example. There is a class PC that extends class 
> Product.
> Take care on the implementation of class Product that implements Persistent 
> interface and
> overwrites jdoLoad() methode.
> 
> Ralf

----------------------------------------------------------- 
If you wish to unsubscribe from this mailing, send mail to
[EMAIL PROTECTED] with a subject of:
        unsubscribe castor-dev

Reply via email to