You are viewing a plain text version of this content. The canonical link for it is here.
Posted to torque-user@db.apache.org by Nuno Miguel Rodrigues <nm...@gmail.com> on 2005/02/10 11:57:23 UTC

Mutual reference

    Hi all,

    I have two tables referencing each other with a foreign key constraint.

    When the respective objects are save()'d, inside a transaction,
the references are each set to 0 (zero), irrespective of the relative
order of the save() calls.

    I currently work around this explicitly setting and getting ids.

    Follows relevant schema excerpts:

<database
  name="mydb"
  defaultIdMethod="idbroker">
    [...]
    <table
      name="object_version">
        <column
          name="id"
          required="true"
          primaryKey="true"
          autoIncrement="true"
          type="INTEGER"/>
        <column
          name="data"
          required="true"
          type="VARCHAR"
          size="255"/>
        <column
          name="effective"
          required="true"
          type="TIMESTAMP"/>
        <column
          name="object_id"
          required="true"
          type="INTEGER"/>
        <foreign-key foreignTable="object">
            <reference
              local="object_id"
              foreign="id"/>
        </foreign-key>
    </table>
    <table
      name="object">
        <column
          name="id"
          required="true"
          primaryKey="true"
          autoIncrement="true"
          type="INTEGER"/>
        <column
          name="version_id"
          required="true"
          type="INTEGER"/>
        <foreign-key foreignTable="object_version">
            <reference
              local="version_id"
              foreign="id"/>
        </foreign-key>
    </table>
    [...]
</database>

    How can I solve this issue?

    TIA,

-- 
Nuno Miguel Rodrigues <nm...@gmail.com>

---------------------------------------------------------------------
To unsubscribe, e-mail: torque-user-unsubscribe@db.apache.org
For additional commands, e-mail: torque-user-help@db.apache.org


Mutual reference

Posted by Nuno Miguel Rodrigues <nm...@gmail.com>.
    Hi all,

    I have two tables referencing each other with a foreign key constraint.

    When the respective objects are save()'d, inside a transaction,
the references are each set to 0 (zero), irrespective of the relative
order of the save() calls.

    I currently work around this explicitly setting and getting ids.

    Follows relevant schema excerpts:

<database
  name="mydb"
  defaultIdMethod="idbroker">
    [...]
    <table
      name="object_version">
        <column
          name="id"
          required="true"
          primaryKey="true"
          autoIncrement="true"
          type="INTEGER"/>
        <column
          name="data"
          required="true"
          type="VARCHAR"
          size="255"/>
        <column
          name="effective"
          required="true"
          type="TIMESTAMP"/>
        <column
          name="object_id"
          required="true"
          type="INTEGER"/>
        <foreign-key foreignTable="object">
            <reference
              local="object_id"
              foreign="id"/>
        </foreign-key>
    </table>
    <table
      name="object">
        <column
          name="id"
          required="true"
          primaryKey="true"
          autoIncrement="true"
          type="INTEGER"/>
        <column
          name="version_id"
          required="true"
          type="INTEGER"/>
        <foreign-key foreignTable="object_version">
            <reference
              local="version_id"
              foreign="id"/>
        </foreign-key>
    </table>
    [...]
</database>

    How can I solve this issue?

    TIA,

--
Nuno Miguel Rodrigues <nm...@gmail.com>

---------------------------------------------------------------------
To unsubscribe, e-mail: torque-user-unsubscribe@db.apache.org
For additional commands, e-mail: torque-user-help@db.apache.org