--~--~---------~--~----~------------~-------~--~----~
Before posting questions to the group please read:
http://groups.google.com/group/transfer-dev/web/how-to-ask-support-questions-on-transfer
Hi Stephen,
I am dealing with the child object though, so getAnswers is not relevant here – I am trying to get to the parent object, which is why I tried getParentQuestion() in the actual answer object.
Transfer 1.0 RC1 – Transfer XML:
<object name="Question" table="tblQuestions" decorator=" model.questions.question">
<id name="ID" type="numeric" />
<property name="PublicID" type="string" column="PublicID" />
<property name="Question" type="string" column="Question" />
<property name="SecondaryInfo" type="string" column="SecondaryInfo" />
<property name="Anonymous" type="numeric" column="Anonymous" />
<property name="PostDate" type="date" column="PostDate" />
<property name="ExpiryDate" type="date" column="ExpiryDate" />
<property name="PosterIP" type="string" column="PosterIP" />
<property name="LastUpdateDate" type="date" column="LastUpdateDate" />
<property name="Rating" type="numeric" column="Rating" />
<property name="NoRatings" type="numeric" column="NoRatings" />
<!-- Link between a question and the user who posted it -->
<manytoone name="User">
<link to="users.Users" column="lnkIDUser"/>
</manytoone>
<!-- Link between a question and the chosen answer style -->
<manytoone name="AnswerStyle">
<link to="question.AnswerStyles" column="lnkIDAnswerStyle"/>
</manytoone>
<!-- Link between a question and it's images -->
<onetomany name="Images">
<link to="question.Image" column="lnkIDQuestion" />
<collection type="array">
<order property="SortOrder" order="asc" />
</collection>
</onetomany>
<!-- Link between a question and it's answers -->
<onetomany name="Answers" lazy="true">
<link to="question.Answer" column="lnkIDQuestion" />
<collection type="array">
<order property="PostDate" order="asc" />
</collection>
</onetomany>
<!-- Link between a question and it's answer choices -->
<onetomany name="AnswerChoices">
<link to="question.AnswerChoices" column="lnkIDQuestion" />
<collection type="array">
<order property="ID" order="asc" />
</collection>
</onetomany>
<!-- Link between the tags and the question -->
<manytomany name="Tags" table="lnkQuestion_Tags">
<link to="question.Question" column="lnkIDQuestion"/>
<link to="question.Tag" column="lnkIDTag"/>
<collection type="struct">
<key property="Tag" />
</collection>
</manytomany>
</object>
The answer object looks like this:
<!-- Answer to a question -->
<object name="Answer" table="tblAnswers" decorator="model.questions.answers.answer">
<id name="ID" type="numeric" />
<property name="AnswerText" type="string" column="AnswerText" />
<property name="AnswerOption" type="numeric" column="AnswerOption" />
<property name="Rating" type="numeric" column="Rating" />
<property name="NoRatings" type="numeric" column="NoRatings" />
<property name="OwnerRating" type="numeric" column="OwnerRating" />
<property name="PosterIP" type="string" column="PosterIP" />
<property name="PostDate" type="date" column="PostDate" />
<!-- Link between an answer and the user who posted it -->
<manytoone name="User">
<link to="users.Users" column="lnkIDUser"/>
</manytoone>
<!-- Link between an answer and the answer choice if answer choice type -->
<manytoone name="AnswerChoice">
<link to="question.AnswerChoices" column="lnkIDAnswerChoice"/>
</manytoone>
<onetomany name="ExtraAnswers">
<link to="question.ExtraAnswer" column="lnkIDParentAnswer" />
<collection type="array">
<order property="ID" order="asc" />
</collection>
</onetomany>
</object>
The answer I call getParentQuestion() on exists and is associated with a valid question.
Thanks,
James.
>
>
> The answer I call getParentQuestion() on exists and is associated with a
> valid question.
>
This must not be the case.
The error you are getting is because the Answer you are calling
'getParent' on, doesn't actually HAVE a Parent. It is quite possible
that you have inadvertently grabbed an unpersisted TransferObject from
Transfer, and therefore it doesn't have a parent.
Mark
Picked an answer from SQL manager which was actual an 'extra answer' - i.e
an extension of an already posted answer and thus a child of it, so it
didn't have a question ID allocated..
Sorry about that guys.. I had it in my head that I would get problems when
trying to access an object from the child if there wasn't a relationship
defined. Should have checked this out in more detail.. It's been a long
day.. :)
Thanks Mark.
-----Original Message-----
From: transf...@googlegroups.com [mailto:transf...@googlegroups.com]
On Behalf Of Mark Mandel
Sent: 11 May 2008 22:29
To: transf...@googlegroups.com
Subject: [transfer-dev] Re: How to get the parent TO from the child