CompositeID reading record assistance

0 views
Skip to first unread message

Loony2nz

unread,
Jul 10, 2008, 4:07:15 PM7/10/08
to transfer-dev
Ok..This is my first foray into the CompositeID realm of Transfer, so
please bear with me :)

Here is the package of my transfer.xml.

<package name="PUBLISHER_ENDORSEMENTS">
<object name="PUBLISHER_ENDORSEMENTS"
table="PUBLISHER_ENDORSEMENTS">
<compositeid>
<manytoone name="PUBLISHER_ID" />
<manytoone name="ENDORSEMENT_ID" />
</compositeid>
<manytoone name="PUBLISHERS">
<link to="PUBLISHERS.PUBLISHERS" column="PUBLISHER_ID"/>
</manytoone>
<manytoone name="ENDORSEMENTS">
<link to="ENDORSEMENTS.ENDORSEMENTS" column="ENDORSEMENT_ID"/
>
</manytoone>
</object>
</package>

I need to know what is the syntax for retrieving all records
pertaining to one particular publisher
(SQL example: select * from publisher_endorsements where publisherID =
1)

Data looks like this:

PublisherID | Endorsement ID
=====================
1 | 3
1 | 6
21 | 1
21 | 5
22 | 2
22 | 4
or something like this.

I was going to try this:
<cfset qGetAllByPublisherID = transfer.getCompositeID("something goes
in here I think") />

again, please excuse my transfer n00bness. :)

Thanks




Loony2nz

unread,
Jul 10, 2008, 4:10:28 PM7/10/08
to transfer-dev
What version of Transfer you are using? 1.0
What CFML Engine you are on, and what version it is? CF8
What database are you using? Oracle
What Operating System you are on ? Windows XP

Jon Messer

unread,
Jul 10, 2008, 4:52:19 PM7/10/08
to transf...@googlegroups.com
You know your model better than I so this might not make sense but I'll make a suggestion anyway...

A ManyToOne doesn't generate any methods in the child object, so unless you add that logic seperately (to a decorator) you won't be able to traverse from your publisher object to the endorsements.

Looking at the definition of PUBLISHER_ENDORSEMENTS, it doesn't seem to have anything other than two foreign keys that make up it's own primary key (A classic join table).

If that's the case I would suggest you either choose a Many to Many from publisher to endorsements (or vise versa if endorsement is more important), or a combination of One to Many and Many to One. But either way the real objects you seem to care about are the publisher and endorsement, not the join.

Then you'd just get a publisher object and have the collections methods to get access to the endorsements that are related.

I know some of this might sound like klingon, if you used to thinking of tables and queries transfer takes a little bit of a mind shift.

Basically I'd suggest you try this with a
publisher manytomany endorsements
or
publisher onetomany publisher_endorsments manytoone endorsments

If that model really is what you want, you won't be able to traverse from publisher to endorsement without writing some custom logic in a decorator or you'd have to resort to sql to retrieve keys...

Again this is just a suggestion, so take it with a grain of salt.

Jennifer Larkin

unread,
Jul 10, 2008, 5:04:38 PM7/10/08
to transf...@googlegroups.com
Sorry, I wrote the composites before I understood the join types, just because we needed to get them up. It should be:
<compositeid>
         <onetomany name="PUBLISHER_ID" />

         <manytoone name="ENDORSEMENT_ID" />
 </compositeid>

Chris is going to change this and see if it improves his situation.
--
I did not come here to get devoured by symbols of monarchy! -- Smirnov of the KGB, Casino Royale

Now blogging....
http://www.blivit.org/blog/index.cfm
http://www.blivit.org/mr_urc/index.cfm

Jon Messer

unread,
Jul 10, 2008, 5:14:59 PM7/10/08
to transf...@googlegroups.com
No reason to apologize  :)

so you are saying you already have publisher  O2M -> publisher_endorsment -> M2O endorsment?

if that's the case then all you need to do is something like this

p = transfer.get('PUBLISHERS.PUBLISHER',1);
a = p.getPUBLISHER_ENDORSEMENTSArray();
for(i=1;i<arrayLen(a);i++){
  a[i].getENDORSEMENT();
// do something with it

Jennifer Larkin

unread,
Jul 10, 2008, 6:41:01 PM7/10/08
to transf...@googlegroups.com
This worked perfectly! Thanks!

I guess next time, instead of apologizing, I should say "But Mark gave me the code!" :D

Loony2nz

unread,
Jul 10, 2008, 7:19:34 PM7/10/08
to transfer-dev
John,

That worked! Had to futz a little with the transfer.xml file, but got
everything working!

Thanks!
Chris

On Jul 10, 2:14 pm, "Jon Messer" <sylvan.mes...@gmail.com> wrote:
> No reason to apologize :)
>
> so you are saying you already have publisher O2M -> publisher_endorsment ->
> M2O endorsment?
>
> if that's the case then all you need to do is something like this
>
> p = transfer.get('PUBLISHERS.PUBLISHER',1);
> a = p.getPUBLISHER_ENDORSEMENTSArray();
> for(i=1;i<arrayLen(a);i++){
> a[i].getENDORSEMENT();
> // do something with it
>
> }
> On Thu, Jul 10, 2008 at 2:04 PM, Jennifer Larkin <jlar...@gmail.com> wrote:
> > Sorry, I wrote the composites before I understood the join types, just
> > because we needed to get them up. It should be:
> > <compositeid>
> > <onetomany name="PUBLISHER_ID" />
> > <manytoone name="ENDORSEMENT_ID" />
> > </compositeid>
>
> > Chris is going to change this and see if it improves his situation.
>
> > On Thu, Jul 10, 2008 at 1:52 PM, Jon Messer <sylvan.mes...@gmail.com>
Reply all
Reply to author
Forward
0 new messages