db-torque-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Nuno M. Rodrigues" <nmrodrig...@gmail.com>
Subject Mutual reference
Date Fri, 11 Feb 2005 18:30:13 GMT

    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 M. Rodrigues <nmrodrigues@gmail.com>



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


Mime
View raw message