db-ojb-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Volker.Kon...@t-systems.com
Subject Handling of multiple-column foreign key
Date Mon, 23 May 2005 12:23:04 GMT
Hello!
Right now I'm testing whether the Persistence Broker of ojb can handle multiple column foreign
key relations. My object-relational mapping looks something like this:

<class-descriptor table="FOO" class="Foo">
 <field-descriptor jdbc-type="INTEGER" column="ID_1" name="id1" primarykey="true" autoincrement="false"/>
 <field-descriptor jdbc-type="INTEGER" column="ID_2" name="id2" primarykey="true" autoincrement="false"/>
 <field-descriptor jdbc-type="INTEGER" column="ID_3" name="id3" primarykey="true" autoincrement="false"/>
 <field-descriptor jdbc-type="CHAR" column="ID_4" name="id4" primarykey="true" autoincrement="false"/>
    
 <!-- reference to Bar -->
 <reference-descriptor auto-retrieve="false" class-ref="Bar" name="bar">
  <foreignkey field-ref="id1"/>
  <foreignkey field-ref="id2"/>
  <foreignkey field-ref="id3"/>
 </reference-descriptor>

<!-- reference to Batz -->
 <reference-descriptor auto-retrieve="true" class-ref="Batz" name="batz">
  <foreignkey field-ref="id4"/>
 </reference-descriptor>
</class-descriptor>


<class-descriptor table="BAR" class="Bar">
 <field-descriptor jdbc-type="INTEGER" column="ID_1" name="id1" primarykey="true" autoincrement="false"/>
 <field-descriptor jdbc-type="INTEGER" column="ID_2" name="id2" primarykey="true" autoincrement="false"/>
 <field-descriptor jdbc-type="INTEGER" column="ID_3" name="id3" primarykey="true" autoincrement="false"/>

<collection-descriptor auto-retrieve="false" element-class-ref="Foo" name="foos">  <inverse-foreignkey
field-ref="id1"/>  <inverse-foreignkey field-ref="id2"/>  <inverse-foreignkey
field-ref="id3"/> </collection-descriptor>

This works fine. If I have some Foo-Instance I'm able to load the Bar-Instance. If I have
a Bar-Instance I can load the Foo-Instance. But if you start mixing the sequence of the primary
key fields and foreign key fields, the PersistenceBroker won't find the references anymore.
If I have an instance of Foo, it fails because the Method BrokerHelper.getKeyValues(ClassDescriptor
cld, Identity oid, boolean convertToSql) relys on sequence but not on column names. If I have
an instance of Bar, it fails because the Method QueryReferenceBroker.getFKQuery1toN(Object
obj, ClassDescriptor cld, CollectionDescriptor cod) also relys on the sequence but not on
column names.

Anyway, It should be no problem for me to provide the object-relational-mapping in the correct
sequence. But in my opinion it is a source for a lot of mistakes that are hard to find. So
I was thinking of patching ojb in this special case, but I don't have a clue about side effects
or time and effort to do this. 

Maybe someone of the developers can give me a hint.

Thank you

Volker

---------------------------------------------------------------------
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