You are viewing a plain text version of this content. The canonical link for it is here.
Posted to ojb-user@db.apache.org by Jakob Braeuchi <jb...@gmx.ch> on 2004/03/11 21:04:29 UTC
Re: Compound Primary Key foreign key references
hi wayne,
Wayne Kidd wrote:
> Although this is, in fact the behavior of OJB, It seems that the right
> behavior should be to describe the referenced tables primary key in the
> sequence of the primary key definition. That is, if the primary key
> constraint gives the order as x,z,y then the referencing table should
> specify that its columns a,b,c refer to pk x,z,y with some syntax like
> <foreignkey field-ref="a" refers-to="x"/>
> <foreignkey field-ref="b" refers-to="z"/>
> <foreignkey field-ref="c" refers-to="y"/>
imo this would lead to less errors when using multicolumn-keys.
i opened a feature-request
http://nagoya.apache.org/scarab/issues/id/OJB249
jakob
>
> instead of assuming the sequence of the column definitions in the other
> table.
>
> Wayne
>
>
> Daniel.B.Brown@wellsfargo.com wrote:
>
>> My question was the later. I could not find the behavior in the
>> documentation.
>>
>> Thanks,
>>
>> - Dan
>>
>> -----Original Message-----
>> From: Ron Gallagher [mailto:rgallagh@bellsouth.net]
>> Sent: Monday, August 18, 2003 9:53 AM
>> To: OJB Users List
>> Subject: Re: Compound Primary Key foreign key references
>>
>>
>> Dan --
>>
>> Are you asking this question because you've tried this configuration
>> and it
>> doesn't work, or are you just confused as to how OJB will handle this
>> situation? If the former, then please provide more info regarding the
>> problems you're having. If the latter, then here's my explanation...
>>
>> Anytime ojb encounters a reference-descriptor, it matches up the
>> foreignkey
>> elements, one for one, with the primary key field-descriptors in the
>> referenced class. This matching process pairs up foreignkey and
>> field-descriptor elements in the same order that they appear in the
>> repository. So, in your case, the property mypackage.ClassA::keyA
>> will be
>> matched up with the property mypackage.ClassB::firstKey, and the property
>> mypackage.ClassA::keyB will be matched up with the property
>> mypackage.ClassB::secondKey
>>
>> Ron Gallagher
>> Atlanta, GA
>> rongallagher@bellsouth.net
>>
>>
>>> From: Daniel.B.Brown@wellsfargo.com
>>> Date: 2003/08/18 Mon AM 09:01:37 EDT
>>> To: ojb-user@db.apache.org
>>> Subject: Compound Primary Key foreign key references
>>>
>>> All,
>>>
>>> From what I can tell, the repository.dtd is not sufficient to uniquely
>>> reference an object with a compound primary key. I think I must be
>>
>>
>> missing
>>
>>> something. In the contrived example below the foreign keys used to
>>> reference class B are keyA and keyB. Unfortunately, the names of
>>> keyA and
>>> keyB are NOT the same names inside classB. How do I configure refB to
>>
>>
>> tell
>>
>>> it that keyA references classB.secondKey and that keyB references
>>> classB.firstKey or vica-versa. I am a little unclear on how to make the
>>> distinction explicit. Any help will be appreciated.
>>>
>>> - Dan
>>>
>>> <class-descriptor class="mypackage.ClassA"
>>> table="tableA"
>>>
>>> <field-descriptor
>>> name="id"
>>> column="id"
>>> jdbc-type="INTEGER"
>>> primarykey="true"
>>> />
>>> <field-descriptor
>>> name="keyA"
>>> column="keyA"
>>> jdbc-type="INTEGER"
>>> />
>>> <field-descriptor
>>> name="keyB"
>>> column="keyB"
>>> jdbc-type="INTEGER"
>>> />
>>> <reference-descriptor
>>> name="refB"
>>> class-ref="mypackage.ClassB"
>>> >
>>> <foreignkey field-ref="keyA"/>
>>> <foreignkey field-ref="keyB"/>
>>> </reference-descriptor>
>>> </class-descriptor>
>>>
>>>
>>> <class-descriptor class="mypackage.ClassB"
>>> table="tableB"
>>>
>>> <field-descriptor
>>> name="firstKey"
>>> column="firstKey"
>>> jdbc-type="INTEGER"
>>> primarykey="true"
>>> />
>>> <field-descriptor
>>> name="secondKey"
>>> column="secondKey"
>>> jdbc-type="INTEGER"
>>> primarykey="true"
>>> />
>>> </class-descriptor>
>>>
>>>> __________________________________________________
>>>> Daniel B. Brown | WELLS FARGO BANK MINNESOTA, N.A. |
>>>> Software Architect | http://www.wellsfargo.com | MAC N2702-011 |
>>>> 9062 Old Annapolis Road | Columbia | MD | 21045-1951 | p:
>>>> 410.884.2034 | f: 410.715.2325 |
>>
>>
>> daniel.b.brown@wellsfargo.com
>>
>>>> |
>>>>
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
>>> For additional commands, e-mail: ojb-user-help@db.apache.org
>>>
>>>
>>
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
>> For additional commands, e-mail: ojb-user-help@db.apache.org
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
> For additional commands, e-mail: ojb-user-help@db.apache.org
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
For additional commands, e-mail: ojb-user-help@db.apache.org