Mark -- 

Based on the snippet from your repository.xml, it appears that you're linking the 
"Interaction" and "User" classes together via the "id" property on the "Interaction" 
class.  When OJB 'resolves' "foreignkey" entries within a "reference-descriptor", it 
uses the value of the property that's identified in the first "foreignkey" entry as 
the value of the first "field-descriptor" in the referenced class.  So, in your case, 
the linkage would look something like this in SQL:

SELECT *
  FROM USERS
     , INTERACTIONS
 WHERE INTERACTIONS.I_ID = USERS.U_ID

If you change the "field-id-ref" on the first "foreignkey" entry from "1" to "2", you 
should see better results.

You also may want to specify a "field-ref" (ie. field-ref="userId") instead of a 
"field-id-ref".  IMO, "field-ref" attributes are a little easier to 
interpret/understand.

HTH

Ron Gallagher
Atlanta, GA
[EMAIL PROTECTED]

> 
> From: "Mark H" <[EMAIL PROTECTED]>
> Date: 2003/02/17 Mon PM 06:52:31 EST
> To: <[EMAIL PROTECTED]>
> Subject: 1:1 associations, can't get it to work
> 
> I know this has been asked many times before but there doesn't seem to be
> any answers that work in the archives. I spent the whole day trying to get
> it to work. When I retrive the object, the referenced object (user) is set
> to null, any ideas? Also is it possible to insert a new 1:1 association
> object?, i.e. will it insert the referenced object first get the PK for it
> and then insert the main object upating the FK?
> 
> Thx in adv.
> Mark
> 
> 
> repository.xml:
> 
> <class-descriptor class="ie.dkit.careers.models.form.User" table="users">
>       <field-descriptor autoincrement="true" column="u_id" id="0"
> jdbc-type="INTEGER" name="id" primarykey="true"/>
>       ...
> </class-descriptor>
> 
> <class-descriptor class="ie.dkit.careers.models.form.Interaction"
> table="interactions">
>       <field-descriptor autoincrement="true" name="id" column="i_id" id="0"
> jdbc-type="INTEGER" primarykey="true"/>
>       <field-descriptor name="userId" column="i_userId" id="1"
> jdbc-type="INTEGER"/>
>       ...
>       <reference-descriptor name="user"
> class-ref="ie.dkit.careers.models.form.User" auto-retrieve="true">
>               <foreignkey field-id-ref="1"/>
>       </reference-descriptor>
> </class-descriptor>
<snip>


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to