Usually 1:1 associations are mapped into foreign key columns on each side .
To my knowlede at this moment there is no nice out-of-the-box solution in OJB that
allows to "reverse" 1:1 associations.
However, if you can enforce that Address object inherit primary key from associatiated
Customer, the following trick may work:
<class-descriptor
class="com.acme.Customer"
>
<field-descriptor
name="primaryKey"
column="PK"
jdbc-type="INTEGER"
primarykey="true"
autoincrement="true"
/>
<reference-descriptor
name="address"
class-ref="com.acme.Address"
auto-retrieve="true"
auto-update="false"
auto-delete="false"
access="readonly"
>
<foreignkey field-ref="primaryKey"/>
</reference-descriptor>
...
----- Original Message -----
From: "Andreas Schildbach" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Monday, January 05, 2004 8:03 AM
Subject: 1-to-1 Associations and Inverse Foreign Key
> Hello everyone,
>
> I've got a 1:1 Association, like a Customer and its Address. In the object model,
> the Address should be navigable from the
Customer, but not the other way round.
>
> The existing database model has got a customer_id foreign key pointing from the
> Address to the primary id of the Customer, instead
of the maybe more usual approach of pointing an address_id foreign key from the
Customer to the primary id of the Address.
>
> This should be no problem, because when navigation in the object model from the
> Customer to its Address, in both cases there is
only one simple select statement needed to find the associated Address.
>
> Unfortunately however, I did not find out how to define the association with an
> "inverse foreign key" in the ODMG descriptor
("repository_user.xml").
>
> According to the repository.dtd, the reference descriptor element only allows
> foreignkey sub-elements but not inverse-foreignkey
sub-elements. The inverse-foreignkey element can only be child of a
collection-descriptor, but that is not what I want (1:1
associations have no need for a collection).
>
> Is there anything I can do in order to allow this?
>
> Regards,
>
> Andreas
>
> BTW: With EJB Entity Beans and JBoss this "decoupling" of the data model navigation
> direction from the direction of the foreign
key is possible.
>
> ______________________________________________________________________________
> Nachrichten, Musik und Spiele schnell und einfach per Quickstart im
> WEB.DE Screensaver - Gratis downloaden: http://screensaver.web.de/?mc=021110
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]