I wrote a mapping like this, the two classes are mapping to same table and class DColor is extends class Color:
<!-- mapping color class to db -->
    <class name="castortest.Color" identity="code">
 
        <description>Color Class</description>
        <cache-type type="none"/>
 
        <map-to table="colorcode" xml="color" />
 
        <field name="code" type="integer">
            <sql name="code" type="integer"/>
            <xml node="attribute"/>
        </field>
 
        <field name="name" type="string">
            <sql name="name" type="char"/>
            <xml node="text"/>
        </field>
 
    </class>
 
<!-- mapping color class to db -->
    <class name="castortest.DColor" extends="castortest.Color" identity="code">
 
        <description>Color Class</description>
        <cache-type type="none"/>
 
        <map-to table="colorcode" xml="bcolor" />
 
        <field name="code" type="integer">
            <sql name="code" type="integer"/>
            <xml node="attribute"/>
        </field>
 
        <field name="desp" type="string">
            <sql name="desp" type="char"/>
            <xml node="text"/>
        </field>
 
    </class>
 
then I create a  DColor instance.
            DColor dcolor = new DColor();
            dcolor.setCode(90);
            dcolor.setDesp("fffff");
            dcolor.setName("aaaaaaaa");
            db.create(dcolor);
after commit, I found that the name field is null in the database.
 
and if I rewrite the DColor's mapping like this:
<!-- mapping color class to db -->
    <class name="castortest.DColor" extends="castortest.Color" identity="code">
 
        <description>Color Class</description>
        <cache-type type="none"/>
 
        <map-to table="colorcode" xml="bcolor" />
 
        <field name="code" type="integer">
            <sql name="code" type="integer"/>
            <xml node="attribute"/>
        </field>
 
        <field name="desp" type="string">
            <sql name="desp" type="char"/>
            <xml node="text"/>
        </field>
 
        <field name="name" type="string">
            <sql name="name" type="char"/>
            <xml node="text"/>
        </field>
 
    </class>
the name value can be set in the database.
 
That's why? Must I write all the super's field in the extends class in mapping file?

Reply via email to