db-jdo-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Andy Jefferson <a...@jpox.org>
Subject Re: equivalent mappings of join condition?
Date Thu, 21 Jul 2005 10:03:57 GMT
Hi Michelle,

> Are the following mappings equivalent?  They differ in the placement of
> the <join> element.

Seem different to me, but since we weren't involved in the design of the ORM 
we only have the spec to go by here

> Mapping 1:
>         <class name="Person" table="persons">
>             <join column="EMPID" table="employee_phoneno_type"/>
>             <field name="phoneNumbers" table="employee_phoneno_type" >
>                 <key column="TYPE"/>
>                 <value column="PHONENO"/>
>             </field>
>         </class>
> Mapping 2:
>         <class name="Person" table="persons">
>             <field name="phoneNumbers" table="employee_phoneno_type" >
>                 <join column="EMPID"/>
>                 <key column="TYPE"/>
>                 <value column="PHONENO"/>
>             </field>
>         </class>
> JPOX appears to treat them differently. 

All in the JPOX docs :-

Mapping 1 has a "Secondary Table" (spec section 15.2), which has nothing in it 
- well it has a Map, but the Map has no columns of its own, so the Secondary 
Table just has a PK. The Map in Mapping 1 is a "ForeignKey" Map (since 
there's no <join> within <field> - meaning that the keys/values are stored in

the value table.
See here http://www.jpox.org/docs/1_1/secondary_tables.html
and here http://www.jpox.org/docs/1_1/relationships_1_N_map.html#fk_uni

In Mapping 2, the Map is a "JoinTable" Map (since there's a <join> within the 
<field>) - meaning that the Map has its key and value (or FK equivalents if 
the key/value are PC) stored in the join table.
See here http://www.jpox.org/docs/1_1/relationships_1_N_map.html#join_pc_pc

Again, this comes down to the interpretation of the <join> within <field>. 
Since JPOX (and other JDO impls for that matter) supports having Maps formed 
with a FK in the value, we interpret the lack of a <join> within the <field> 
as saying that we should store the linkage between map and value as a FK in 
the value (This is consistent with Collections where there is no <join> 
within <field> being interpreted as having a FK in the element).

Criticise away ;-)

It's good to see that the TCK is flushing out all possible differences of 
interpretation in ORM. There are so many ways of representing relationships, 
and JPOX supports what our users feel are the most common.


View raw message