Hi,
I have a question about foreign keys and manytoone relationships. I
have a Transfer object like this:
<package name="CMS">
<object name="text" table="texts">
<id name="id" type="numeric"/>
<property name="menuid" type="numeric" column="FK_Menuid"
nullable="false" />
<property name="title" type="string" column="title" nullable="false" /
>
<property name="text" type="string" column="text" nullable="false" />
<property name="contentInfo" type="string" column="contentInfo"
nullable="true" />
<property name="dateFrom" type="date" column="dateFrom"
nullable="true" />
<property name="showDateFrom" type="boolean" column="showdateFrom" />
<property name="dateTo" type="date" column="dateTo" nullable="true" /
>
<property name="showDateTo" type="boolean" column="showDateTo" />
<manytoone name="status">
<link to="CMS.status" column="FK_status"/>
</manytoone>
<manytoone name="group">
<link to="CMS.group" column="FK_group"/>
</manytoone>
<manytoone name="language">
<link to="Language.language" column="FK_language"/>
</manytoone>
<manytoone name="objectType">
<link to="CMS.objectType" column="FK_objectType"/>
</manytoone>
</object>
...
</package>
I retrieve a new text object like this:
<cfset local.oText=transfer.new("CMS.text")>
I update the transfer object's value for the FK_objectTypeId with
<!--- get the transfer object 'objectType' that corresponds to the
object with the given id value --->
<cfset local.oObjectType=transfer.get
("CMS.objectType",formdata.objectTypeId)>
<--- update the CMSobject's foreign key value --->
<cfset local.oText.setObjectType(local.oObjectType)>
(CMS.objectType is defined also in the transfer.xml file, I don't show
it for brevity)
When I want to save the text object with
<cfset transfer.save(local.oText)>
I get a message
Column 'FK_objectType' cannot be null
So I think "OK, that makes sense since I did not specify the property
FK_objectType' in the object and then Transfer wants to insert a null
value in this column which I forbade in MySQL"
So I add this line:
<property name="FK_objectType" type="numeric" column="FK_objectType'" /
>
to the CMS.text object.
Now when I want to save the object I get this message:
Column 'FK_objectType' specified twice
So I don't know. Do I have to specify this column FK_objectType as a
property and _also_ tell transfer this column is a foreign key in the
manytoone block _or_ do I only have to define this column in the
onetomany block?
Either case I get an error.
Or should I not use a manytoone relationship in this case at all and
just retrieve a corresponding objecttype object manually if I need to?
What is the correct way of defining a foreign key in the transfer.xml
file and updating it with a value and saving?
Hope I made myself clear.
Marc
--~--~---------~--~----~------------~-------~--~----~
Before posting questions to the group please read:
http://groups.google.com/group/transfer-dev/web/how-to-ask-support-questions-on-transfer
You received this message because you are subscribed to the Google Groups
"transfer-dev" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/transfer-dev?hl=en
-~----------~----~----~----~------~----~------~--~---