db-ojb-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Matt Mastrangelo <mm...@ccs.neu.edu>
Subject Tables with multiple unique keys
Date Mon, 13 Jan 2003 21:53:36 GMT
When doing a 1:1 mapping using a reference-descriptor, OJB appears to
identify the relationship only through primary key fields.  For example:

<class-descriptor class="Child" table="CHILD_TABLE">
  <field-descriptor name="OID" ..... primarykey="true" />
  <field-descriptor name="parentOID" ..... />
  <reference-descriptor name="parent" class-ref="Child">
    <foreignkey field-ref="parentOID" />
  </reference-descriptor>
</class-descriptor>

In the above case, the relationship between Child and Parent will be
established by looking in the class-descriptor for Parent and finding the
field-descriptor with primarykey=true.

This seems to cause a limitation of one key per table.  Oftentimes in
databases, a "parent" record can be identified by different unique keys,
for example, by its object ID or by its natural primary key.  In some
situations it may be more beneficial to reference a parent record by either
one or the other.

Here is an example of what I'd like to do:

<class-descriptor class="Child" table="CHILD_TABLE">
  <field-descriptor name="OID" ..... primarykey="true" />
  <field-descriptor name="parentOID" ..... />
  <reference-descriptor name="parent" class-ref="Child">
    <foreignkey field-ref="parentOID" related-field="Parent.OID" />
  </reference-descriptor>
</class-descriptor>

The added parameter "related-field" would offer the flexibility of being
able to specify which field(s) in the parent table on which to base the
relationship, instead of having to always rely on the ones that have
"primarykey=true".

Is there a way to do something equivalent to this?  If not, are there
plans to ever implement such a feature?

Thanks,
Matt

Mime
View raw message