Hi Robert,

It should not be too difficult, I've added all kind of methods to my 
decorators. This is how I'd do it:

1. The model persists its data in 3 tables for the 2 objects and their many 
to many relationship (foos, bars and lnk_FooBar). Transfer.xml should look 
something like:

<object name="Foo" table="foos" >
 <id name="FooId" column="FOO_ID" type="GUID" generate="true" />
 <property name="Name" type="string" column="name" />
...
 <manytomany name="Bars" table="lnk_FooBar">
  <link to="...Foo" column="lnkIDFoo"/>
  <link to="...Bar" column="lnkIDBar"/>
  <collection type="array"/>
 </manytomany>
</object>

<object name="Bar" table="bars" decorator="...decorators.Bar">
 <id name="BarId" column="BAR_ID" type="GUID" generate="true" />
 <property name="Name" type="string" column="name" />
...
</object>

The table lnkFooBar should only consist of 2 columns, lnkIDFoo and lnkIDBar.

2. In the decorator for Bar, I'd add the following method:

<cffunction name="getParentFoos" access="public" returntype="Array">
 <cfset var foos = ArrayNew(1) />
 <cfset var qry = getTransfer().createQuery("FROM ...Foo JOIN ...Bar WHERE 
...Bar.BarId = :myId") />
 <cfset var foosQuery = "" />

 <cfset qry.setParam("myId", getBarId()) />
 <cfset foosQuery = getTransfer().listByQuery(qry) />
 <cfloop query="foosQuery">
  <cfset ArrayAppend(foos, getTransfer().get("...Foo", foosQuery.FooId) ) />
 </cfloop>
 <cfreturn foos />
</cffunction>

Every "..." should be replaced with the package name. A similar method could 
obtain structs.

HTH,

Pedro.

-- 
Before posting questions to the group please read:
http://groups.google.com/group/transfer-dev/web/how-to-ask-support-questions-on-transfer

Try out the new Transfer ORM Custom Google Search:
http://www.google.com/cse/home?cx=002375903941309441958:2s7wbd5ocb8

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

Reply via email to