How would a m2m work on the DB side as a composite key?
Mark
Under:
http://docs.transfer-orm.com/wiki/Using_Composite_Keys.cfm#Configuration
The class attribute found on the parentonetomany is the class name of
a object that has a onetomany composite element that points to the
current object configuration.
Let me know if that neesds to be clarified better.
Mark
I need to ask if you have looked at any of the same applications out there?
There are several, and they outline many of the relationships that you
can set up, and how you use them.
I highly recommend that you do have a look at the example
applications, as that is what they are there for.
Mark
I have Users, which have onetomany Groups. My transfer definition
looks like this:
<package name="Users">
<object name="User" table="Users" decorator="_model.Users.UserDecorator">
<id name="ID" type="numeric" />
<property name="Username" type="string" column="Username" />
<property name="Password" type="string" column="Password" />
<property name="FirstName" type="string" column="FirstName" />
<property name="LastName" type="string" column="LastName" />
<property name="EmailAddress" type="string" column="EmailAddress" />
<property name="Confirmed" type="boolean" column="Confirmed" />
<property name="GUID" type="string" column="GUID" />
<property name="stamp" type="date" column="stamp" />
<property name="stampupdated" type="date" column="stampupdated" />
<onetomany name="Groups" lazy="true">
<link to="Groups.Group" column="UserID"/>
<collection type="array">
<order property="SortOrder" order="asc" />
</collection>
</onetomany>
</object>
</package>
<package name="Groups">
<object name="Group" table="Groups" decorator="_model.Groups.GroupDecorator">
<id name="ID" type="numeric" />
<!--
Don't set this as a property since it's part of a manytoone relationship
<property name="UserID" type="numeric" column="UserID" />
-->
<property name="GroupLabel" type="string" column="GroupLabel" />
<property name="SortOrder" type="numeric" column="SortOrder" />
<property name="stamp" type="date" column="stamp" />
<property name="stampupdated" type="date" column="stampupdated" />
<manytomany name="Items" table="GroupsItems">
<link to="Groups.Group" column="GroupID"/>
<link to="Items.Item" column="ItemID"/>
<collection type="array" />
</manytomany>
</object>
</package>
</package>
If I try to do something like this in a validate method it fails:
<cfset LOCAL.PropertyMap = {UserID = getUserID(), GroupLabel =
getGroupLabel()} />
<cfset LOCAL.groupnameCheck =
getTransfer().listByPropertyMap("Groups.Group", LOCAL.PropertyMap) />
It fails with:
The property 'USERID' could not be found in the object 'Groups.Group'
It seems to me that I should have implicit access to that property
since it's a foreign key in the table... If I add it as a property to
the Groups I get duplicate column name errors from SQL. It seems to me
wasteful that I always have to go get the parent object before I can
get the children. It also complicates the application as a whole since
intead of the two line bit of code above to check and see whether a
group name already exists for a user, I either have to get a user
object first, or I have to write TQL to do it instead.
Dan