Title: 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>



Reply via email to