I believe the problem solved a while ago. It is in the CVS.
If you don't uses autoStore(), it is user responsibility to create object in
sequence.
If autoStore() is used, Castor walked the tree, and marked object to be
created.
Then, it creates object that do not depends on other ids first. And, the
create object depends on the created object, and so on.




Thomas

-----Original Message-----
>From: Keith Chew SL [mailto:[EMAIL PROTECTED]]
>Sent: Saturday, October 20, 2001 7:48 AM
>To: [EMAIL PROTECTED]
>Subject: [castor-dev] Found JDO bug
>
>Hi
>
>I posted a mail recently about the Product -> ProductGroup problem
(Castor's
>example). Basically, when you:
>(1) create a ProductGroup
>(2) assign it to a new Product
>(3) create new Product
>
>Castor will extract the ProductGroups's id and insert it into the group_id
>field. Here's the snippet of the Product's mapping:
>    <!--  Product has reference to ProductGroup,
>          many products may reference same group  -->
>    <field name="group" type="myapp.ProductGroup">
>      <sql name="group_id" />
>      <xml name="group" node="element" />
>    </field>
>
>OK, here's the catch. If you create a key generator (I used HIGH/LOW) and
>make ProductGroup use it, Castor cannot create the Product object. The
>group_id will be left as null and the DB will complain with: "ERROR:
>ExecAppend: Fail to add null value in not null attribute group_id" (This is
>from postgresql).
>
>To reproduce this problem just add this to the mapping.xml and create the
>keys table:
>
>  <key-generator name="HIGH/LOW">
>    <param name="table" value="keys"/>
>    <param name="key-column" value="table_name"/>
>    <param name="value-column" value="max_pk_value"/>
>    <param name="grab-size" value="1000"/>
>  </key-generator>
>
>  <!--  Mapping for ProductGroup  -->
>  <class name="myapp.ProductGroup"
>         identity="id" access="shared" key-generator="HIGH/LOW">
>    <description>Product group</description>
>    <map-to table="prod_group" xml="group" />
>    <cache-type type="unlimited"/>
>    <field name="id" type="integer" >
>      <sql name="id" type="integer"/>
>      <xml node="element"/>
>    </field>
>    <field name="name" type="string">
>      <sql name="name" type="char" />
>      <xml node="element" />
>    </field>
>  </class>
>
>Can someone in the Castor team look into this problem please?
>
>Keith C
>
>-----------------------------------------------------------
>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

Reply via email to