link table with 3 separate columns in other table

7 views
Skip to first unread message

phipps_73

unread,
Jun 4, 2010, 11:29:43 AM6/4/10
to Reactor
Hi all,

I wonder if anyone can come up with a suggestion to get the following
to work with Reactor:

I have a tbldocuments table which contains a docid, documentpath etc.
I then have another table: tblrecruitment.

tblrecruitment has various columns but the relevant columns are
iddocid, wpdocid and spdocid. These 3 relate to tbldocuments but not
as a composite key. Each of the columns in tblrecruitment needs a
separate relationship with the docid in tbldocuments.

Is there a way to do this in Reactor so that I can load the
recruitment object and then load the related documents using one or
more of the recruitment docid fields.

So lets say there is a value in iddocid and spdocid. Then I would want
to load 2 tbldocument records, one where iddocid = docid and then
spdocid = docid like so:

oRecruitment.gettbldocument() // get the iddocid > docid related
record
oRecruitment.gettbldocument() // get the spdocid > docid related
record

Do I need to create an alias somewhere? Here is a snip of my reactor
config:

<object name="tblrecruitment">
<hasOne name="tbldocuments">
<relate from="iddocid" to="docid" />
</hasOne>
<hasOne name="tbldocuments">
<relate from="wpdocid" to="docid" />
</hasOne>
<hasOne name="tbldocuments">
<relate from="spdocid" to="docid" />
</hasOne>
</object>

If this is not possible do I just use the recruitment docid's
(iddocid, spdocid, wpdocid) to do a getByFields on a
tbldocumentsGateway?

Cheers,

Dave

Chris Blackwell

unread,
Jun 6, 2010, 7:37:17 AM6/6/10
to reactor-users
You just need to give each reference to tbldocuments a unique alias

<object name="tblrecruitment">
       <hasOne name="tbldocuments" alias="doc1">

               <relate from="iddocid" to="docid" />
       </hasOne>
       <hasOne name="tbldocuments" alias="doc2">
               <relate from="wpdocid" to="docid" />
       </hasOne>
       <hasOne name="tbldocuments" alias="doc3">
               <relate from="spdocid" to="docid" />
       </hasOne>
</object>

then you can access the related documents by calling getDoc1()  etc..

Cheers, Chris

Dave Phipps

unread,
Jun 8, 2010, 3:41:01 AM6/8/10
to reacto...@googlegroups.com
I was thinking along the correct lines then, just couldn't work out
which option from the docs would be the right way to go. I'll go with
your suggestion.

Thanks for the help.

Cheers,

Dave

> --
> You received this message because you are subscribed to the Google Groups
> "Reactor" group.
> To post to this group, send email to reacto...@googlegroups.com.
> To unsubscribe from this group, send email to
> reactor-user...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/reactor-users?hl=en.
>

Reply all
Reply to author
Forward
0 new messages