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 "McCaffrey, John G." <Jo...@kraft.com> on 2004/03/18 20:33:09 UTC
1 to 1 mapping
I am trying to join two tables A and B
table A has three primary keys
Main_ID
Node_ID
Process_Date
table B has two primary keys
Node_ID
Process_Date
my mapping has the Table A object containing a collection of B obj
I want to join the collection using the Node_ID, because it is the only
thing they can be joined on
when I do the mapping
<collection-descriptor name="aObj" element-class-ref="x.x.x.AObj"
proxy="false" auto-retrieve="true" >
<inverse-foreignkey field-ref="node_ID"/>
</collection-descriptor>
it complains about an arrayIndexOutOfBounds
but it works when the only primary key is Node_ID
i don't get it
---------------------------------------------------------------------
To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
For additional commands, e-mail: ojb-user-help@db.apache.org
Re: 1 to 1 mapping
Posted by Armin Waibel <ar...@apache.org>.
Hi John,
you have to declare all PK fields in the collection/reference-descriptor
inverse-foreignkey/foreignkey tags.
McCaffrey, John G. wrote:
> I am trying to join two tables A and B
> table A has three primary keys
> Main_ID
> Node_ID
> Process_Date
>
> table B has two primary keys
> Node_ID
> Process_Date
>
> my mapping has the Table A object containing a collection of B obj
ok, you have an 1:n reference from A to B, thus your
collection-descriptor should look like
<class-descriptor for A>
...
<collection-descriptor
name="allBs"
element-class-ref="B"
proxy="false"
auto-retrieve="true" >
<inverse-foreignkey field-ref="FK_node_ID"/>
<inverse-foreignkey field-ref="FK_main_ID"/>
<inverse-foreignkey field-ref="FK_process_date"/>
</collection-descriptor>
...
</class-descriptor>
Means your B class needs three FK fields (to map the PK of A).
regards,
Armin
> I want to join the collection using the Node_ID, because it is the only
> thing they can be joined on
>
> when I do the mapping
>
> <collection-descriptor name="aObj" element-class-ref="x.x.x.AObj"
> proxy="false" auto-retrieve="true" >
> <inverse-foreignkey field-ref="node_ID"/>
> </collection-descriptor>
>
> it complains about an arrayIndexOutOfBounds
> but it works when the only primary key is Node_ID
>
> i don't get it
>
>
> ---------------------------------------------------------------------
> 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
Re: 1 to 1 mapping
Posted by Edson Carlos Ericksson Richter <ed...@mgrinformatica.com.br>.
Use a reference-descriptor to make 1:1 mappings. If you are using 1:N mappings, use a collection-descriptor in the 1 side, and a reference-descriptor in the N side.
Best regards,
Edson Richter
----- Original Message -----
From: McCaffrey, John G.
To: 'OJB Users List'
Sent: Thursday, March 18, 2004 4:33 PM
Subject: 1 to 1 mapping
I am trying to join two tables A and B
table A has three primary keys
Main_ID
Node_ID
Process_Date
table B has two primary keys
Node_ID
Process_Date
my mapping has the Table A object containing a collection of B obj
I want to join the collection using the Node_ID, because it is the only
thing they can be joined on
when I do the mapping
<collection-descriptor name="aObj" element-class-ref="x.x.x.AObj"
proxy="false" auto-retrieve="true" >
<inverse-foreignkey field-ref="node_ID"/>
</collection-descriptor>
it complains about an arrayIndexOutOfBounds
but it works when the only primary key is Node_ID
i don't get it
---------------------------------------------------------------------
To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
For additional commands, e-mail: ojb-user-help@db.apache.org
---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.624 / Virus Database: 401 - Release Date: 15/3/2004