I must be doing something wrong, but I can't figure out what it is.  I'm 
using JDO to store a complext object.  I have the mapping below and 
basically it is an agreement object which has a collection of objective 
objects which in tern have a collection of threshold objects.

Notice the objective has a "agreement_id" field which is used to join to 
the identity of the agreement and likewise the threshold has a 
"objective_id" field which is used to join to the objective identity.

If I use the mapping below without "key=generator" set and I set my own 
identity values and fill in the "agreement_id" and "objective_id" fields 
I can store and retrieve the object.  However if I turn on key-generator 
then either
1) I set the agreement_id and object_id fields and then they don't match 
the generated identifies
2) I leave them null and then I get a SQL error because the non nullable 
field isn't set.

How do I get Castor JDO to initalize the join field?

Thanks for all the help

-Brian


                <!DOCTYPE databases PUBLIC "-//EXOLAB/Castor Mapping DTD 
Version 1.0//EN"
                           "http://castor.exolab.org/mapping.dtd";>
                <mapping>
                    <class name="com.amberpoint.domain.DObject1"
                          identity="id" key-generator="UUID" >
                    <description>The mapping for the agreement DObject 
class</description>
                    <map-to table="Agreements" xml="agreement" />
                    <field name="id" type="string"
                        handler="com.amberpoint.domain.DObjectHandler">
                        <sql name="id" type="char"/>
                        <bind-xml node="attribute"/>
                    </field>
                    <field name="name" type="string"
                        handler="com.amberpoint.domain.DObjectHandler">
                        <sql name="name" type="varchar" dirty="check" />
                        <bind-xml node="attribute"/>
                    </field>
                    <field name="active" type="boolean"
                        handler="com.amberpoint.domain.DObjectHandler">
                        <sql name="active" type="varchar" dirty="check" />
                        <bind-xml node="attribute"/>
                    </field>
                    <field name="description" type="string"
                        handler="com.amberpoint.domain.DObjectHandler">
                        <sql name="description" type="varchar" 
dirty="check" />
                        <bind-xml node="element" />
                    </field>
                    <field name="usageDomain" type="string"
                        handler="com.amberpoint.domain.DObjectHandler">
                        <sql name="usage_domain" type="varchar" 
dirty="check" />
                        <bind-xml node="element" />
                    </field>
                    <field name="usageCondition" type="string"
                        handler="com.amberpoint.domain.DObjectHandler">
                        <sql name="usage_condition" type="varchar" 
dirty="check" />
                        <bind-xml node="element" />
                    </field>
                    <field name="objectives" 
type="com.amberpoint.domain.DObject2"
                        handler="com.amberpoint.domain.DObjectHandler"
                        collection="collection" >
                        <sql many-key="agreement_id" />
                        <bind-xml name="objective" node="element" />
                    </field>
                    </class>

                    <!-- agreement objectives -->
                    <class name="com.amberpoint.domain.DObject2"
                          identity="id" key-generator="UUID"
                          depends="com.amberpoint.domain.DObject1" >
                    <description>The mapping for the objectives DObject 
class</description>
                    <map-to table="Agreement_Objectives" xml="objective" />
                    <field name="id" type="string"
                        handler="com.amberpoint.domain.DObjectHandler">
                        <sql name="id" type="char"/>
                        <bind-xml node="attribute"/>
                    </field>
                    <field name="agreementId" type="string"
                        handler="com.amberpoint.domain.DObjectHandler">
                        <sql name="agreement_id" type="char"/>
                        <bind-xml node="attribute"/>
                    </field>
                    <field name="serviceId" type="string"
                        handler="com.amberpoint.domain.DObjectHandler">
                        <sql name="service_id" type="varchar" 
dirty="check" />
                        <bind-xml node="attribute"/>
                    </field>
                    <field name="operationId" type="string"
                        handler="com.amberpoint.domain.DObjectHandler">
                        <sql name="operation_id" type="varchar" 
dirty="check" />
                        <bind-xml node="attribute"/>
                    </field>
                    <field name="instrumentId" type="string"
                        handler="com.amberpoint.domain.DObjectHandler">
                        <sql name="instrument_id" type="varchar" 
dirty="check" />
                        <bind-xml node="attribute"/>
                    </field>
                    <field name="condition" type="string"
                        handler="com.amberpoint.domain.DObjectHandler">
                        <sql name="condition" type="varchar" 
dirty="check" />
                        <bind-xml node="element" />
                    </field>
                    <field name="thresholds" 
type="com.amberpoint.domain.DObject3"
                        handler="com.amberpoint.domain.DObjectHandler"
                        collection="collection" >
                        <sql many-key="objective_id" />
                        <bind-xml name="threshold" node="element" />
                    </field>
                    </class>

                    <!-- agreement thresholds -->
                    <class name="com.amberpoint.domain.DObject3"
                          identity="id" key-generator="UUID"
                          depends="com.amberpoint.domain.DObject1" >
                    <description>The mapping for the 
thresholds</description>
                    <map-to table="Agreement_Thresholds" xml="threshold" />
                    <field name="id" type="string"
                        handler="com.amberpoint.domain.DObjectHandler">
                        <sql name="id" type="char"/>
                        <bind-xml node="attribute"/>
                    </field>
                    <field name="objectiveId" type="string"
                        handler="com.amberpoint.domain.DObjectHandler">
                        <sql name="objective_id" type="char"/>
                        <bind-xml node="attribute"/>
                    </field>
                    <field name="instrumentId" type="string"
                        handler="com.amberpoint.domain.DObjectHandler">
                        <sql name="instrument_id" type="varchar" 
dirty="check" />
                        <bind-xml node="attribute"/>
                    </field>
                    <field name="level" type="integer"
                        handler="com.amberpoint.domain.DObjectHandler">
                        <sql name="level" type="integer" dirty="check" />
                        <bind-xml node="element" />
                    </field>
                    </class>
                </mapping>

-- 
   __o 
 _-\<,_   Brian
(_)/ (_)  [EMAIL PROTECTED]  x503
 

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

Reply via email to