New objects aren't cached... so.. I'm not sure what you are driving at here?
Unless your 'save' is running, regardless of if your validate() has failed?
Mark
No I checked the DB and nothing is saved. Is this happening because I am
attaching the object to it's parent. I.E this is a new answer being created
which has a setParentQuestion() method run to tie it to an already persisted
question. Therefore the answer appears immediately even if I don't save it.
Once I re-init transfer it goes. Here's the creation code:
<cfargument name="ID" type="numeric" default="0" />
<cfargument name="AnswerText" type="string" required="false"
/>
<cfargument name="AnswerOption" type="numeric"
required="false" />
<cfargument name="Rating" type="numeric" required="false" />
<cfargument name="PosterIP" type="string" required="false"
/>
<cfargument name="PostDate" type="date" required="false" />
<cfargument name="userBean" type="component"
required="false" />
<cfargument name="questionBean" type="question"
required="false" />
<cfset var answerBean =
variables.instance.transfer.new("question.Answer") />
<cfif len(AnswerText)><cfset
answerBean.setAnswerText(answerText) /></cfif>
<cfif len(AnswerOption)><cfset
answerBean.setAnswerOption(answerOption) /></cfif>
<cfif len(Rating)><cfset answerBean.setRating(rating)
/></cfif>
<cfif len(PosterIP)><cfset answerBean.setPosterIP(PosterIP)
/></cfif>
<cfif len(PostDate)><cfset answerBean.setPostDate(PostDate)
/></cfif>
<cfif StructKeyExists(arguments,"questionBean") AND
isObject(questionBean)>
<cfset answerBean.setParentQuestion(questionBean)>
</cfif>
<cfif StructKeyExists(arguments,"userBean") AND
isObject(userBean)>
<cfset answerBean.setUser(userBean)>
</cfif>
<cfreturn answerBean />
Cheers,
James.
Failing that, you should be able to clone the parent, and then save it that way.
Mark
The parent cloning idea might work a treat though - thanks.
I'll go this route in future then if it's the recommended approach.