Hi,

I have an object, "Role" and an object "Rights". Roles and Rights have a 
manyToMany relation. I want to associate multiple rights to a role. The 
roles and rights are static - only the linking table gets updated to reflect 
which rights are associated with a given role.

I figure to do it like this:

(RightsIds = a list of rights that I want to associate to a role)

<cfloop list="#RightsIds#" index="Rightsid">
    <!--- adding rights to role nr 1 --->
    <cfset role=Transfer.get("Role",1)>
    <cfset role.addRights(Transfer.get("Right",Rightsid))>
    Transfer.save(role)
</cfloop>

Is this the fastest way or can I do all this in 1 statement?

Btw this is the relevant Transfer.xml snippet

        <object name="rights" >
            <id name="id" type="numeric" />
            <property name="description" type="string" nullable="true" />
            <property name="rightKey" type="string" nullable="false" />
            <property name="label" type="string" nullable="false" />
            <manytomany name="role" table="roleRight" >
                <link to="rights" column="FK_right"/>
                <link to="role" column="FK_role"/>
                <collection type="array">
                    <order property="label" order="asc" />
                </collection>
            </manytomany>
        </object>


        <object name="role">
            <id name="id" type="numeric" />
            <property name="description" type="string" nullable="true" />
            <property name="roleKey" type="string" nullable="false" />
            <property name="label" type="string" nullable="false" />
            <manytomany name="rights" table="roleRight" lazy="true">
                <link to="rights" column="FK_right"/>
                <link to="role" column="FK_role"/>
                <collection type="array">
                    <order property="label" order="asc" />
                </collection>
            </manytomany>
        </object>

Marc

-- 
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