db-ojb-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Antonio Gallardo" <agalla...@agsoftware.dnsalias.com>
Subject [BUG?] In order of FK description @ <reference-descriptor>
Date Mon, 15 Dec 2003 21:56:55 GMT
Hi:

I found the follwing problem. I am not sure if this is a bug or lack of
documentation. Anyway, I think we need to see this:

I have a 2 fields Primary Key (PK) on a class A defined as follow:

<class-descriptor class="test.A" table="A">
  <field-descriptor name="id_1" primarykey="true" default-fetch="true"
      column="ID_A" jdbc-type="INTEGER"/>
  <field-descriptor name="id_2" primarykey="true" default-fetch="true"
      column="ID_B" jdbc-type="INTEGER"/>
  <collection-descriptor name="bList" element-class-ref="test.b"
          auto-update="false" auto-delete="false">
      <inverse-foreignkey field-ref="id_1"/>
      <inverse-foreignkey field-ref="id_2"/>
  </collection-descriptor>
</class-descriptor>

Please note the order how are defined the PK. First is id_1 then id_2! Now
the secodn class:

<class-descriptor class="test.B" table="B">
  <field-descriptor name="id" primarykey="true" default-fetch="true"
      column="ID_A" jdbc-type="INTEGER"/>
  <field-descriptor name="id_2" default-fetch="true"
      column="ID_B" jdbc-type="INTEGER"/>
  <field-descriptor name="id_1" default-fetch="true"
      column="ID_A" jdbc-type="INTEGER"/>
  <reference-descriptor name="A" class-ref="test.A"
          auto-update="false" auto-delete="false">
      <foreignkey field-ref="id_1"/>
      <foreignkey field-ref="id_2"/>
  </reference-descriptor>
</class-descriptor>

Seems like the order of the defined inverse-foreign keys is very important
(not documented at all website) since if in the sample we change the
"order" of id_1 and id_2 in both above describe <class-descriptor> just in
the <collection descriptor> of class A and the <reference-descriptor> of
class B We got an referential integrity error, reference from B not found
in A!

Note the order of fields in class B, (first id_2, follow id_1) they are
intentionally changed as they are in class A.

I hope the problem is good explained, if not please let me know. I will
try to explain it better.

Best Regards,

Antonio Gallardo


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


Mime
View raw message