I've a very similar problem. I do understand Andrew's conclusion, but I have the following additional question:
If the VolumeCustomer class would be used as a child of another class (using many-key), how would Castor know to only pull the VolumeCustomer objects and not the Customer objects when loading the parent object from the database? Thanks, Achim -----Original Message----- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]] Sent: Friday, May 24, 2002 10:30 AM To: [EMAIL PROTECTED] Subject: Re: [castor-dev] JDO Inheritence OK. I think I have found the problem. Because all the classes (base and subclasses) map to the same database table, I have to specify all the field mappings in the xml files, Castor doesn't know to go to the superclass and get the fields from there when mapping. This would be a great feature! -----Original Message----- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]] Sent: 23 May 2002 18:30 To: [EMAIL PROTECTED] Subject: Re: [castor-dev] JDO Inheritence Oh, This class that sits in between is an abstract class. <!DOCTYPE databases PUBLIC "-//EXOLAB/Castor Mapping DTD Version 1.0//EN" "http://castor.exolab.org/mapping.dtd"> <mapping> <!-- Mapping for Volume Customer --> <class name="com.vwfs.VolumeCustomer" extends="com.vwfs.Customer"> <description>Mapping for Volume Customer, which simply extends a Customer</description> <map-to table="customers" xml="customer" /> <field name="sName" type="string" get-method="getName" set-method="setName"> <sql name="name" type="char" /> <xml name="name" node="element" /> </field> <field name="sAddress" type="string" get-method="getAddress" set-method="setAddress"> <sql name="address" type="char" /> <xml name="address" node="element" /> </field> <field name="sCity" type="string" get-method="getCity" set-method="setCity"> <sql name="city" type="char" /> <xml name="city" node="element" /> </field> <field name="sState" type="string" get-method="getState" set-method="setState"> <sql name="state" type="char" /> <xml name="state" node="element" /> </field> <field name="sZipCode" type="string" get-method="getZipCode" set-method="setZipCode"> <sql name="zip_code" type="char" /> <xml name="zip_code" node="element" /> </field> </class> </mapping> 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 ----------------------------------------------------------- If you wish to unsubscribe from this mailing, send mail to [EMAIL PROTECTED] with a subject of: unsubscribe castor-dev ----------------------------------------------------------- If you wish to unsubscribe from this mailing, send mail to [EMAIL PROTECTED] with a subject of: unsubscribe castor-dev ----------------------------------------------------------- If you wish to unsubscribe from this mailing, send mail to [EMAIL PROTECTED] with a subject of: unsubscribe castor-dev
