Marc
unread,Sep 16, 2011, 3:09:41 PM9/16/11Sign in to reply to author
Sign in to forward
You do not have permission to delete messages in this group
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to transf...@googlegroups.com
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