Title: Re: [CFCDev] cftransaction

Move the cftransaction tag outside the try/catch and you’ll be fine.

 

Stace

 


From: Lamotte Denis [mailto:[EMAIL PROTECTED]
Sent: Friday, December 17, 2004 10:45 AM
To: [EMAIL PROTECTED]
Subject: Re: [CFCDev] cftransaction

 


>From sean cordfield previosu message

> then if any method call throws an exception, CF will roll back *all*
> of the database changes made by the methods as long as they all refer
> to the same datasource.

That's not always true , unfortunately !!
If there is an _expression_ error or any other type of error,
 when reaching <cftransaction action=""  you ‘ll have an error
Java.langException.nullvalue (or something like that) and nothing in the transaction is rolling back
And I never find a way to get rid of them.

If you look at the code below (used in a mach-ii app)

If any error occurred outside precatched exception than you cannot control the

 <cftry>
    <cftransaction action="" />

    <cfset defaultDataUserObj=createDefaultUser() />
    <cfset userDao.create(defaultDataUserObj) />
    <cfset DataBean.setProperty("DataUserID",defaultDataUserObj.getproperty("UserID")) />
    <cfset application.ApplicationBean.getProperty("datadao").create(dataBean)/>

 <cfcatch type="DATADAO.create.NONUNIQUE.title">
    <cfset DATAbean.setInvalidFields("title") />
    <cfset DATAbean.setInvalidFieldsMessage("title","title already Taken") />
    <cfset EventArgs["DATAbean"] = DATAbean />
    <cfset Continue= false />
 </cfcatch>
 <cfcatch type="DATADAO.create.NONUNIQUE.path">
    <cfset DATAbean.setInvalidFields("path") />
    <cfset DATAbean.setInvalidFieldsMessage("path","path already Taken") />
    <cfset EventArgs["DATAbean"] = DATAbean />
    <cfset Continue= false />
 </cfcatch>
 <cfcatch type="any">
 <!--- some other DAO-generated exception --->
    <cftransaction action="">     <cfrethrow />
 </cfcatch>

 </cftry>

 <cfif Continue >
    <cftransaction action="">     <cfset announceEvent("createDATASuccessEvent", EventArgs) />
 <cfelse>
    <cftransaction action="">     <cfset announceEvent("createDATAFailureEvent", EventArgs) />
 </cfif>

 </cffunction>




AVIS IMPORTANTWARNING

Les informations contenues dans le present document et ses pieces jointes sont strictement confidentielles et reservees a l'usage de la (des) personne(s) a qui il est adresse. Si vous n'etes pas le destinataire, soyez avise que toute divulgation, distribution, copie, ou autre utilisation de ces informations est strictement prohibee. Si vous avez recu ce document par erreur, veuillez s'il vous plait communiquer immediatement avec l'expediteur et detruire ce document sans en faire de copie sous quelque forme.

The information contained in this document and attachments is confidential and intended only for the person(s) named above. If you are not the intended recipient you are hereby notified that any disclosure, copying, distribution, or any other use of the information is strictly prohibited. If you have received this document by mistake, please notify the sender immediately and destroy this document and attachments without making any copy of any kind.


Reply via email to