Hi Michelle,

the two mappings differ in the presence of the join condition. They would be equivalent, if there is a default for the <join> element which is "EMPID".

Michael and I looked into the spec. We could not find a default for the <join> element, neither in chapter 15.2 (Join Condition) nor in chapter 18.8 (ELEMENT join). Thus, I conclude that there is no default.

For this reason, I do not consider both mappings equivalent and you would have to use mapping 2. However, if mapping 1 is used then it would be nice to receive a different exception, e.g. JDOUserException("Unsupported mapping for field Person.phoneNumbers: missing <join> element.").

Regards,
Michael

Hi,

Are the following mappings equivalent? They differ in the placement of the <join> element.

Mapping 1:
       <class name="Person" table="persons">
<datastore-identity strategy="identity" column="DATASTORE_IDENTITY"/>
           <inheritance strategy="new-table">
<discriminator strategy="class-name" column="DISCRIMINATOR"/>
           </inheritance>
           <join column="EMPID" table="employee_phoneno_type"/>
           <field name="personid" column="PERSONID"/>
           <field name="firstname" column="FIRSTNAME"/>
           <field name="lastname" column="LASTNAME"/>
           <field name="middlename" column="MIDDLENAME"/>
           <field name="address">
               <embedded null-indicator-column="COUNTRY">
                   <field name="addrid" column="ADDRID"/>
                   <field name="street" column="STREET"/>
                   <field name="city" column="CITY"/>
                   <field name="state" column="STATE"/>
                   <field name="zipcode" column="ZIPCODE"/>
                   <field name="country" column="COUNTRY"/>
               </embedded>
           </field>
           <field name="phoneNumbers" table="employee_phoneno_type" >
               <key column="TYPE"/>
               <value column="PHONENO"/>
           </field>
       </class>

Mapping 2:
       <class name="Person" table="persons">
<datastore-identity strategy="identity" column="DATASTORE_IDENTITY"/>
           <inheritance strategy="new-table">
<discriminator strategy="class-name" column="DISCRIMINATOR"/>
           </inheritance>
           <field name="personid" column="PERSONID"/>
           <field name="firstname" column="FIRSTNAME"/>
           <field name="lastname" column="LASTNAME"/>
           <field name="middlename" column="MIDDLENAME"/>
           <field name="address">
               <embedded null-indicator-column="COUNTRY">
                   <field name="addrid" column="ADDRID"/>
                   <field name="street" column="STREET"/>
                   <field name="city" column="CITY"/>
                   <field name="state" column="STATE"/>
                   <field name="zipcode" column="ZIPCODE"/>
                   <field name="country" column="COUNTRY"/>
               </embedded>
           </field>
           <field name="phoneNumbers" table="employee_phoneno_type" >
               <join column="EMPID"/>
               <key column="TYPE"/>
               <value column="PHONENO"/>
           </field>
       </class>

JPOX appears to treat them differently. When mapping 1 is used, an apparent attempt to insert values (nulls) into the employee_phoneno_type table results in an error: "ERROR 23502: Column 'PHONENO' cannot accept a NULL value". Mapping 2 executes without error.

-- Michelle


--
-------------------------------------------------------------------
Michael Watzek                  [EMAIL PROTECTED] Engineering GmbH
mailto:[EMAIL PROTECTED]        Buelowstr. 66
Tel.:  ++49/30/235 520 36       10783 Berlin - Germany
Fax.:  ++49/30/217 520 12       http://www.spree.de/
-------------------------------------------------------------------

Reply via email to