In which case, you would want to join the ObjectType to the content type.

Remember Transfer knows about Objects, not about relational data structures,
so TQL works that way as well.

There are actually a stack of examples on the google group of this question,
but google group's search facilities have been totally fubar'd for a long
time.

Mark

On Thu, Oct 22, 2009 at 8:31 AM, marc <[email protected]> wrote:

>
> Ok, so I keep having problems with defining (or not defining) the
> property. According to the wiki if I use a foreign key I should not
> use a <property ...> line with that column name since it is already
> defined in a m2o relationship:
>
>                        <object name="text" table="texts">
>                                <id name="id" type="numeric"/>
>                                <property name="menuid" type="numeric"
> column="FK_Menuid"
> nullable="false" />
>                                 <property name="showDateTo" type="boolean"
> column="showDateTo" />
>                                 <manytoone name="objectType">
>                                        <link to="CMS.objectType"
> column="FK_objectType"/>
>                                </manytoone>
>                        </object>
>
> should not contain the property
>
> <property name="FK_objectType" type="numeric" column="FK_objectType" /
> >
>
> since it is already defined in
>
> <link to="CMS.objectType" column="FK_objectType"/>
>
> But if I do this and then want a listing of a textobjects via a
> listByQuery:
>
> <cfset local.query=transfer.createQuery("SELECT
> CMS.#contentType#.id,CMS.#contentType#.title,CMS.#contentType#.contentInfo
> FROM CMS.#contentType# JOIN CMS.objectType WHERE
> CMS.#contentType#.FK_objectType = :objectType")>
> <cfset local.query.setParam("objectType","2","numeric")>
> <cfset local.result["#contentType#"]=transfer.listByQuery(local.query)
> >
> (where contentType="text")
> I get
>
> The property 'FK_objectType' could not be found in the object
> 'CMS.text'
>
> So what does this error message mean? If I add the property to the
> object definition I get errors later on.
>
> Marc
>
> On Oct 21, 10:42 pm, Mark Mandel <[email protected]> wrote:
> > So you were totally headed in the right direction the first time.
> >
> > The FK value for a M2O is determined by what object is in that
> relationship.
> >
> > If there is no Object in that relationship, it attempts to insert NULL.
> > See:
> http://docs.transfer-orm.com/wiki/Handling_Null_Values.cfm#Foreign_Keys
> >
> > This means that somewhere along the lines, that relationship is not
> actually
> > being set in your code.
> >
> > Mark
> >
> >
> >
> > On Thu, Oct 22, 2009 at 5:25 AM, marc <[email protected]> wrote:
> > > 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"
> >
> > --
> > E: [email protected]
> > T:http://www.twitter.com/neurotic
> > W:www.compoundtheory.com
> >
>


-- 
E: [email protected]
T: http://www.twitter.com/neurotic
W: www.compoundtheory.com

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

Reply via email to