Hi,

I have an issue with JDO inheritence.
Say I have a Customer class with some fields.
I have a Corporation class which extends Customer, this class has 2 new
fields. 
They both enter data into 1 table - customers.

When I try to insert into Customer, that works fine, however when using
Corporation, it tries to perform and insert using only the 2 fields defined
(seemingly ignoring the fields in the superclass 'Customer'), so I get SQL
errors such as invalid column types etc.
Can someone tell me if my mappings are incorrect, or if there is a problem
with Castor doing this type of thing (which I don't think there would/should
be).

Thanks

xml mappings
=====================
<!DOCTYPE databases PUBLIC "-//EXOLAB/Castor Mapping DTD Version 1.0//EN"
                           "http://castor.exolab.org/mapping.dtd";>

<mapping>
        <!--  Mapping for com.vwfs.Customer  -->
        <class name="com.vwfs.Customer" identity="iCustomerID"
key-generator="MAX">

        <description>com.vwfs.Customer</description>
        <map-to table="customers" xml="customer" />

        <field name="iCustomerID" type="integer" get-method="getCustomerID"
set-method="setCustomerID">
                <sql name="customer_id" type="integer" />
                <xml name="customer_id" node="element" />
        </field>

        <field name="iCustomerTypeID" type="integer"
get-method="getCustomerTypeID" set-method="setCustomerTypeID"
required="true">
                <sql name="customer_type_id" type="integer" />
                <xml name="customer_type_id" node="element" />
        </field>

        <field name="sNickname" type="string" get-method="getNickname"
set-method="setNickname">
                <sql name="nickname" type="char" />
                <xml name="nickname" node="element" />
        </field>
        
        <field name="iVersion" type="integer" get-method="getVersion"
set-method="setVersion">
                <sql name="version" type="integer" />
                <xml name="version" node="element" />
        </field>

        <field name="sEmailAddress" type="string"
get-method="getEmailAddress" set-method="setEmailAddress">
                <sql name="email_address" type="char" />
                <xml name="email_address" node="element" />
        </field>

        <field  name="theCustomerType" 
                        type="com.vwfs.CustomerType" 
                        get-method="getCustomerType" 
                        set-method="setCustomerType"
                        required="true">
                        <sql many-key="customer_type_id"/>
        </field>  
        
        <field  name="theCustomerTrackedRecordings"
                        type="com.vwfs.CustomerTrackedRecording"
                        get-method="getCustomerTrackedRecordings"
                        set-method="setCustomerTrackedRecordings"       
                        lazy="true"
                        collection="collection"
                        required="false">
        </field>        
        </class>
</mapping>



<!DOCTYPE databases PUBLIC "-//EXOLAB/Castor Mapping DTD Version 1.0//EN"
                           "http://castor.exolab.org/mapping.dtd";>

<mapping>
        <!--  Mapping for com.vwfs.Corporation  -->
        <class name="com.vwfs.Corporation"
extends="com.vwfs.VolumeCustomer">

        <description>com.vwfs.Corporation</description>
        <map-to table="customers" xml="customer" />

        <field name="sCompanyName" type="string" get-method="getCompanyName"
set-method="setCompanyName">
                <sql name="company_name" type="char" />
                <xml name="company_name" node="element" />
        </field>

     </class>
</mapping>

==========================================
Logger output:
[com.vwfs.CustomerType] SQL for creating com.vwfs.Customer: INSERT INTO
"CUSTOMERS"
("CUSTOMER_ID","CUSTOMER_TYPE_ID","NICKNAME","VERSION","EMAIL_ADDRESS")
VALUES (?,?,?,?,?)

[com.vwfs.CustomerType] SQL for creating com.vwfs.Corporation: INSERT INTO
"CUSTOMERS" ("CUSTOMER_ID","COMPANY_NAME") VALUES (?,?)



**********************************************************************************

The opinions expressed in this E-mail are those  of  the individual  and
not  necessarily  the  company.  This E-mail and  any files transmitted 
with it are confidential and solely for the use of the intended recipients

**********************************************************************************

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

Reply via email to